Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions openfeature/multi/multiprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"log/slog"
"maps"
"slices"
"strings"
"sync"

Expand Down Expand Up @@ -48,11 +49,12 @@ type (
globalHooks []of.Hook
}

// NamedProvider extends [of.FeatureProvider] by adding a unique provider name. The Name method returns
// the assigned provider name, while provider returns the underlying [of.FeatureProvider] instance.
// NamedProvider extends [of.FeatureProvider] by adding a unique provider name.
NamedProvider interface {
of.FeatureProvider
// Name returns the unique name assigned to the provider.
Name() string
// unwrap returns the underlying [of.FeatureProvider] instance.
unwrap() of.FeatureProvider
}

Expand Down Expand Up @@ -171,8 +173,8 @@ func WithCustomStrategy(s StrategyConstructor) Option {
}

// WithGlobalHooks sets the global hooks for the provider. These are [of.Hook] instances that affect ALL [of.FeatureProvider]
// instances. For hooks that target specific providers make sure to attach them to that provider directly, or use the
// [WithProviderHooks] [Option] if that provider does not provide its own hook functionality.
// instances. To apply hooks to specific providers, attach them directly to that provider, or include them in the [WithProvider] [Option]
// if the provider does not support its own hook functionality.
func WithGlobalHooks(hooks ...of.Hook) Option {
return func(conf *configuration) {
conf.hooks = hooks
Expand Down
5 changes: 2 additions & 3 deletions openfeature/multi/multiprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package multi
import (
"context"
"errors"
"regexp"
"testing"
"time"

Expand All @@ -25,10 +24,10 @@ func TestMultiProvider_ProvidersMethod(t *testing.T) {
assert.Len(t, p, 2)
assert.NotNil(t, p[0])
assert.Implements(t, (*of.FeatureProvider)(nil), p[0])
assert.Regexp(t, regexp.MustCompile("provider1"), p[0].Name())
assert.Equal(t, "provider1", p[0].Name())
assert.NotNil(t, p[1])
assert.Implements(t, (*of.FeatureProvider)(nil), p[1])
assert.Regexp(t, regexp.MustCompile("provider2"), p[1].Name())
assert.Equal(t, "provider2", p[1].Name())
}

func TestMultiProvider_NewMultiProvider(t *testing.T) {
Expand Down
Loading