From 3472ee897827542991935111b8895e8c18fa6bec Mon Sep 17 00:00:00 2001 From: gunishmatta Date: Fri, 3 May 2024 13:32:42 +0530 Subject: [PATCH] code review changes --- openfeature/client.go | 13 ++++++------- pkg/openfeature/client.go | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/openfeature/client.go b/openfeature/client.go index 4a357a81..4d54d007 100644 --- a/openfeature/client.go +++ b/openfeature/client.go @@ -38,15 +38,14 @@ type IClient interface { // ClientMetadata provides a client's metadata type ClientMetadata struct { - domain string - name string + name string } // NewClientMetadata constructs ClientMetadata // Allows for simplified hook test cases while maintaining immutability -func NewClientMetadata(domain string) ClientMetadata { +func NewClientMetadata(name string) ClientMetadata { return ClientMetadata{ - domain: domain, + name: name, } } @@ -58,7 +57,7 @@ func (cm ClientMetadata) Name() string { // Domain returns the client's domain func (cm ClientMetadata) Domain() string { - return cm.domain + return cm.name } // Client implements the behaviour required of an openfeature client @@ -76,7 +75,7 @@ var _ IClient = (*Client)(nil) // NewClient returns a new Client. Name is a unique identifier for this client func NewClient(domain string) *Client { return &Client{ - metadata: ClientMetadata{domain: domain}, + metadata: ClientMetadata{name: domain}, hooks: []Hook{}, evaluationContext: EvaluationContext{}, logger: globalLogger, @@ -692,7 +691,7 @@ func (c *Client) evaluate( } // ensure that the same provider & hooks are used across this transaction to avoid unexpected behaviour - provider, globalHooks, globalCtx := forTransaction(c.metadata.domain) + provider, globalHooks, globalCtx := forTransaction(c.metadata.name) evalCtx = mergeContexts(evalCtx, c.evaluationContext, globalCtx) // API (global) -> client -> invocation apiClientInvocationProviderHooks := append(append(append(globalHooks, c.hooks...), options.hooks...), provider.Hooks()...) // API, Client, Invocation, Provider diff --git a/pkg/openfeature/client.go b/pkg/openfeature/client.go index 80ddb4fe..9abe3c9e 100644 --- a/pkg/openfeature/client.go +++ b/pkg/openfeature/client.go @@ -29,7 +29,7 @@ func NewClientMetadata(name string) ClientMetadata { // Deprecated: use github.com/open-feature/go-sdk/openfeature.Client, instead. type Client = openfeature.Client -// NewClient returns a new Client. Domain is a unique identifier for this client +// NewClient returns a new Client. Name is a unique identifier for this client // // Deprecated: use github.com/open-feature/go-sdk/openfeature.NewClient, // instead.