Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make provider interface "stateless" #299

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 4 additions & 5 deletions e2e/evaluation_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ package e2e_test

import (
"context"
"strings"
"testing"

"github.com/open-feature/go-sdk/openfeature"
"github.com/open-feature/go-sdk/openfeature/memprovider"
"strings"
"testing"
)

func setupFuzzClient(f *testing.F) *openfeature.Client {
f.Helper()

memoryProvider := memprovider.NewInMemoryProvider(map[string]memprovider.InMemoryFlag{})
err := openfeature.SetProvider(memoryProvider)
err := openfeature.SetNamedProviderAndWait(f.Name(), memoryProvider)
if err != nil {
f.Errorf("error setting up provider %v", err)
}

return openfeature.NewClient("fuzzing")
return openfeature.GetApiInstance().GetNamedClient(f.Name()).(*openfeature.Client)
}

func FuzzBooleanEvaluation(f *testing.F) {
Expand Down
32 changes: 15 additions & 17 deletions e2e/evaluation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/open-feature/go-sdk/openfeature/memprovider"
)

var client = openfeature.NewClient("evaluation tests")

// ctxStorageKey is the key used to pass test data across context.Context
type ctxStorageKey struct{}

Expand Down Expand Up @@ -95,7 +93,7 @@ func initializeEvaluationScenario(ctx *godog.ScenarioContext) {
func aProviderIsRegisteredWithCacheDisabled(ctx context.Context) error {
memoryProvider := memprovider.NewInMemoryProvider(memoryFlags)

err := openfeature.SetProvider(memoryProvider)
err := openfeature.SetNamedProvider("evaluation-test", memoryProvider)
if err != nil {
return err
}
Expand All @@ -111,7 +109,7 @@ func aBooleanFlagWithKeyIsEvaluatedWithDefaultValue(
return ctx, errors.New("default value must be of type bool")
}

got, err := client.BooleanValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").BooleanValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -140,7 +138,7 @@ func theResolvedBooleanValueShouldBe(ctx context.Context, expectedValueStr strin
func aStringFlagWithKeyIsEvaluatedWithDefaultValue(
ctx context.Context, flagKey, defaultValue string,
) (context.Context, error) {
got, err := client.StringValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").StringValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand All @@ -164,7 +162,7 @@ func theResolvedStringValueShouldBe(ctx context.Context, expectedValue string) e
func anIntegerFlagWithKeyIsEvaluatedWithDefaultValue(
ctx context.Context, flagKey string, defaultValue int64,
) (context.Context, error) {
got, err := client.IntValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").IntValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand All @@ -188,7 +186,7 @@ func theResolvedIntegerValueShouldBe(ctx context.Context, expectedValue int64) e
func aFloatFlagWithKeyIsEvaluatedWithDefaultValue(
ctx context.Context, flagKey string, defaultValue float64,
) (context.Context, error) {
got, err := client.FloatValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").FloatValue(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand All @@ -210,7 +208,7 @@ func theResolvedFloatValueShouldBe(ctx context.Context, expectedValue float64) e
}

func anObjectFlagWithKeyIsEvaluatedWithANullDefaultValue(ctx context.Context, flagKey string) (context.Context, error) {
got, err := client.ObjectValue(ctx, flagKey, nil, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").ObjectValue(ctx, flagKey, nil, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -272,7 +270,7 @@ func aBooleanFlagWithKeyIsEvaluatedWithDetailsAndDefaultValue(
return ctx, errors.New("default value must be of type bool")
}

got, err := client.BooleanValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").BooleanValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -316,7 +314,7 @@ func theResolvedBooleanDetailsValueShouldBeTheVariantShouldBeAndTheReasonShouldB
func aStringFlagWithKeyIsEvaluatedWithDetailsAndDefaultValue(
ctx context.Context, flagKey, defaultValue string,
) (context.Context, error) {
got, err := client.StringValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").StringValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -355,7 +353,7 @@ func theResolvedStringDetailsValueShouldBeTheVariantShouldBeAndTheReasonShouldBe
func anIntegerFlagWithKeyIsEvaluatedWithDetailsAndDefaultValue(
ctx context.Context, flagKey string, defaultValue int64,
) (context.Context, error) {
got, err := client.IntValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").IntValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -394,7 +392,7 @@ func theResolvedIntegerDetailsValueShouldBeTheVariantShouldBeAndTheReasonShouldB
func aFloatFlagWithKeyIsEvaluatedWithDetailsAndDefaultValue(
ctx context.Context, flagKey string, defaultValue float64,
) (context.Context, error) {
got, err := client.FloatValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").FloatValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -433,7 +431,7 @@ func theResolvedFloatDetailsValueShouldBeTheVariantShouldBeAndTheReasonShouldBe(
func anObjectFlagWithKeyIsEvaluatedWithDetailsAndANullDefaultValue(
ctx context.Context, flagKey string,
) (context.Context, error) {
got, err := client.ObjectValueDetails(ctx, flagKey, nil, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").ObjectValueDetails(ctx, flagKey, nil, openfeature.EvaluationContext{})
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -540,7 +538,7 @@ func aFlagWithKeyIsEvaluatedWithDefaultValue(
return ctx, errors.New("no contextAwareEvaluationData found")
}

got, err := client.StringValue(ctx, flagKey, defaultValue, ctxAwareEvalData.evaluationContext)
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").StringValue(ctx, flagKey, defaultValue, ctxAwareEvalData.evaluationContext)
if err != nil {
return ctx, fmt.Errorf("openfeature client: %w", err)
}
Expand Down Expand Up @@ -570,7 +568,7 @@ func theResolvedFlagValueIsWhenTheContextIsEmpty(ctx context.Context, expectedRe
return errors.New("no contextAwareEvaluationData found")
}

got, err := client.StringValue(
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").StringValue(
ctx, ctxAwareEvalData.flagKey, ctxAwareEvalData.defaultValue, openfeature.EvaluationContext{},
)
if err != nil {
Expand All @@ -587,7 +585,7 @@ func theResolvedFlagValueIsWhenTheContextIsEmpty(ctx context.Context, expectedRe
func aNonexistentStringFlagWithKeyIsEvaluatedWithDetailsAndADefaultValue(
ctx context.Context, flagKey, defaultValue string,
) (context.Context, error) {
got, err := client.StringValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").StringValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})

return context.WithValue(ctx, ctxStorageKey{}, stringFlagNotFoundData{
evalDetails: got,
Expand Down Expand Up @@ -644,7 +642,7 @@ func theReasonShouldIndicateAnErrorAndTheErrorCodeShouldIndicateAMissingFlagWith
func aStringFlagWithKeyIsEvaluatedAsAnIntegerWithDetailsAndADefaultValue(
ctx context.Context, flagKey string, defaultValue int64,
) (context.Context, error) {
got, err := client.IntValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})
got, err := openfeature.GetApiInstance().GetNamedClient("evaluation-test").IntValueDetails(ctx, flagKey, defaultValue, openfeature.EvaluationContext{})

return context.WithValue(ctx, ctxStorageKey{}, typeErrorData{
evalDetails: got,
Expand Down
20 changes: 0 additions & 20 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cucumber/gherkin/go/v26 v26.2.0 h1:EgIjePLWiPeslwIWmNQ3XHcypPsWAHoMCz/YEBKP4GI=
github.com/cucumber/gherkin/go/v26 v26.2.0/go.mod h1:t2GAPnB8maCT4lkHL99BDCVNzCh1d7dBhCLt150Nr/0=
github.com/cucumber/godog v0.14.0 h1:h/K4t7XBxsFBF+UJEahNqJ1/2VHVepRXCSq3WWWnehs=
github.com/cucumber/godog v0.14.0/go.mod h1:FX3rzIDybWABU4kuIXLZ/qtqEe1Ac5RdXmqvACJOces=
github.com/cucumber/godog v0.14.1 h1:HGZhcOyyfaKclHjJ+r/q93iaTJZLKYW6Tv3HkmUE6+M=
github.com/cucumber/godog v0.14.1/go.mod h1:FX3rzIDybWABU4kuIXLZ/qtqEe1Ac5RdXmqvACJOces=
github.com/cucumber/messages/go/v21 v21.0.1 h1:wzA0LxwjlWQYZd32VTlAVDTkW6inOFmSM+RuOwHZiMI=
Expand All @@ -11,12 +9,9 @@ github.com/cucumber/messages/go/v22 v22.0.0/go.mod h1:aZipXTKc0JnjCsXrJnuZpWhtay
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.3.1+incompatible h1:0/KbAdpx3UXAx1kEOWHJeOkpbgRFGHVgv+CFIY7dBJI=
github.com/gofrs/uuid v4.3.1+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
Expand All @@ -31,7 +26,6 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b
github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE=
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
Expand All @@ -57,12 +51,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo=
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
Expand All @@ -79,14 +67,6 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
19 changes: 19 additions & 0 deletions openfeature/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Client struct {
metadata ClientMetadata
hooks []Hook
evaluationContext EvaluationContext
domain string

mx sync.RWMutex
}
Expand All @@ -56,6 +57,7 @@ func NewClient(name string) *Client {

func newClient(name string, apiRef evaluationImpl, eventRef clientEvent) *Client {
return &Client{
domain: name,
api: apiRef,
clientEventing: eventRef,
metadata: ClientMetadata{name: name},
Expand All @@ -64,6 +66,11 @@ func newClient(name string, apiRef evaluationImpl, eventRef clientEvent) *Client
}
}

// State returns the state of the associated provider
func (c *Client) State() State {
toddbaert marked this conversation as resolved.
Show resolved Hide resolved
return c.clientEventing.State(c.domain)
}

// Deprecated
// WithLogger sets the logger of the client
func (c *Client) WithLogger(l logr.Logger) *Client {
Expand Down Expand Up @@ -677,6 +684,18 @@ func (c *Client) evaluate(
c.finallyHooks(ctx, hookCtx, providerInvocationClientApiHooks, options)
}()

// short circuit if provider is in NOT READY state
if c.State() == NotReadyState {
c.errorHooks(ctx, hookCtx, providerInvocationClientApiHooks, ProviderNotReadyError, options)
return evalDetails, ProviderNotReadyError
}

// short circuit if provider is in FATAL state
if c.State() == FatalState {
c.errorHooks(ctx, hookCtx, providerInvocationClientApiHooks, ProviderFatalError, options)
return evalDetails, ProviderFatalError
}

evalCtx, err = c.beforeHooks(ctx, hookCtx, apiClientInvocationProviderHooks, evalCtx, options)
hookCtx.evaluationContext = evalCtx
if err != nil {
Expand Down
30 changes: 30 additions & 0 deletions openfeature/client_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func ExampleNewClient() {
}

func ExampleClient_BooleanValue() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
client := openfeature.NewClient("example-client")
value, err := client.BooleanValue(
context.Background(), "test-flag", true, openfeature.EvaluationContext{},
Expand All @@ -29,6 +32,9 @@ func ExampleClient_BooleanValue() {
}

func ExampleClient_StringValue() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
client := openfeature.NewClient("example-client")
value, err := client.StringValue(
context.Background(), "test-flag", "openfeature", openfeature.EvaluationContext{},
Expand All @@ -42,6 +48,9 @@ func ExampleClient_StringValue() {
}

func ExampleClient_FloatValue() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
client := openfeature.NewClient("example-client")
value, err := client.FloatValue(
context.Background(), "test-flag", 0.55, openfeature.EvaluationContext{},
Expand All @@ -55,6 +64,9 @@ func ExampleClient_FloatValue() {
}

func ExampleClient_IntValue() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
client := openfeature.NewClient("example-client")
value, err := client.IntValue(
context.Background(), "test-flag", 3, openfeature.EvaluationContext{},
Expand All @@ -68,6 +80,9 @@ func ExampleClient_IntValue() {
}

func ExampleClient_ObjectValue() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
client := openfeature.NewClient("example-client")
value, err := client.ObjectValue(
context.Background(), "test-flag", map[string]string{"foo": "bar"}, openfeature.EvaluationContext{},
Expand All @@ -82,6 +97,9 @@ func ExampleClient_ObjectValue() {
}

func ExampleClient_Boolean() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
ctx := context.Background()
client := openfeature.NewClient("example-client")

Expand All @@ -95,6 +113,9 @@ func ExampleClient_Boolean() {
}

func ExampleClient_String() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
ctx := context.Background()
client := openfeature.NewClient("example-client")

Expand All @@ -104,6 +125,9 @@ func ExampleClient_String() {
}

func ExampleClient_Float() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
ctx := context.Background()
client := openfeature.NewClient("example-client")

Expand All @@ -113,6 +137,9 @@ func ExampleClient_Float() {
}

func ExampleClient_Int() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
ctx := context.Background()
client := openfeature.NewClient("example-client")

Expand All @@ -122,6 +149,9 @@ func ExampleClient_Int() {
}

func ExampleClient_Object() {
if err := openfeature.SetNamedProviderAndWait("example-client", openfeature.NoopProvider{}); err != nil {
log.Fatalf("error setting up provider %v", err)
}
ctx := context.Background()
client := openfeature.NewClient("example-client")

Expand Down
Loading
Loading