From f3e8cf692c27639c2a474ed0c8479f6edaf251af Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 12 Aug 2024 14:30:11 -0400 Subject: [PATCH 1/3] feat!: domain instead of client name Signed-off-by: Todd Baert --- README.md | 38 ++++++------ src/OpenFeature/Api.cs | 30 +++++----- src/OpenFeature/ProviderRepository.cs | 22 +++---- .../OpenFeatureClientBenchmarks.cs | 6 +- .../OpenFeatureClientTests.cs | 60 +++++++++---------- .../OpenFeatureEventTests.cs | 8 +-- .../OpenFeature.Tests/OpenFeatureHookTests.cs | 4 +- test/OpenFeature.Tests/OpenFeatureTests.cs | 4 +- 8 files changed, 87 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index 6844915f..bce047f8 100644 --- a/README.md +++ b/README.md @@ -69,16 +69,16 @@ public async Task Example() ## 🌟 Features -| Status | Features | Description | -| ------ | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| βœ… | [Providers](#providers) | Integrate with a commercial, open source, or in-house feature management tool. | -| βœ… | [Targeting](#targeting) | Contextually-aware flag evaluation using [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context). | -| βœ… | [Hooks](#hooks) | Add functionality to various stages of the flag evaluation life-cycle. | -| βœ… | [Logging](#logging) | Integrate with popular logging packages. | -| βœ… | [Named clients](#named-clients) | Utilize multiple providers in a single application. | -| βœ… | [Eventing](#eventing) | React to state changes in the provider or flag management system. | -| βœ… | [Shutdown](#shutdown) | Gracefully clean up a provider during application shutdown. | -| βœ… | [Extending](#extending) | Extend OpenFeature with custom providers and hooks. | +| Status | Features | Description | +| ------ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| βœ… | [Providers](#providers) | Integrate with a commercial, open source, or in-house feature management tool. | +| βœ… | [Targeting](#targeting) | Contextually-aware flag evaluation using [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context). | +| βœ… | [Hooks](#hooks) | Add functionality to various stages of the flag evaluation life-cycle. | +| βœ… | [Logging](#logging) | Integrate with popular logging packages. | +| βœ… | [Domains](#domains) | Logically bind clients with providers. | +| βœ… | [Eventing](#eventing) | React to state changes in the provider or flag management system. | +| βœ… | [Shutdown](#shutdown) | Gracefully clean up a provider during application shutdown. | +| βœ… | [Extending](#extending) | Extend OpenFeature with custom providers and hooks. | > Implemented: βœ… | In-progress: ⚠️ | Not implemented yet: ❌ @@ -96,7 +96,7 @@ await Api.Instance.SetProviderAsync(new MyProvider()); ``` In some situations, it may be beneficial to register multiple providers in the same application. -This is possible using [named clients](#named-clients), which is covered in more detail below. +This is possible using [domains](#domains), which is covered in more detail below. ### Targeting @@ -151,27 +151,29 @@ var value = await client.GetBooleanValueAsync("boolFlag", false, context, new Fl The .NET SDK uses Microsoft.Extensions.Logging. See the [manual](https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line) for complete documentation. -### Named clients +### Domains -Clients can be given a name. -A name is a logical identifier that can be used to associate clients with a particular provider. -If a name has no associated provider, the global provider is used. +Clients can be assigned to a domain. +A domain is a logical identifier which can be used to associate clients with a particular provider. +If a domain has no associated provider, the default provider is used. ```csharp // registering the default provider await Api.Instance.SetProviderAsync(new LocalProvider()); -// registering a named provider +// registering a provider to a domain await Api.Instance.SetProviderAsync("clientForCache", new CachedProvider()); // a client backed by default provider FeatureClient clientDefault = Api.Instance.GetClient(); // a client backed by CachedProvider -FeatureClient clientNamed = Api.Instance.GetClient("clientForCache"); - +FeatureClient scopedClient = Api.Instance.GetClient("clientForCache"); ``` +Domains can be defined on a provider during registration. +For more details, please refer to the [providers](#providers) section. + ### Eventing Events allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes, diff --git a/src/OpenFeature/Api.cs b/src/OpenFeature/Api.cs index 3fa38916..821567b5 100644 --- a/src/OpenFeature/Api.cs +++ b/src/OpenFeature/Api.cs @@ -50,19 +50,19 @@ public async Task SetProviderAsync(FeatureProvider featureProvider) } /// - /// Sets the feature provider to given clientName. In order to wait for the provider to be set, and + /// Binds the feature provider to the given domain. In order to wait for the provider to be set, and /// initialization to complete, await the returned task. /// - /// Name of client + /// An identifier which logically binds clients with providers /// Implementation of - public async Task SetProviderAsync(string clientName, FeatureProvider featureProvider) + public async Task SetProviderAsync(string domain, FeatureProvider featureProvider) { - if (string.IsNullOrWhiteSpace(clientName)) + if (string.IsNullOrWhiteSpace(domain)) { - throw new ArgumentNullException(nameof(clientName)); + throw new ArgumentNullException(nameof(domain)); } - this._eventExecutor.RegisterClientFeatureProvider(clientName, featureProvider); - await this._repository.SetProviderAsync(clientName, featureProvider, this.GetContext(), this.AfterInitialization, this.AfterError).ConfigureAwait(false); + this._eventExecutor.RegisterClientFeatureProvider(domain, featureProvider); + await this._repository.SetProviderAsync(domain, featureProvider, this.GetContext(), this.AfterInitialization, this.AfterError).ConfigureAwait(false); } /// @@ -82,14 +82,14 @@ public FeatureProvider GetProvider() } /// - /// Gets the feature provider with given clientName + /// Gets the feature provider with given domain /// - /// Name of client - /// A provider associated with the given clientName, if clientName is empty or doesn't + /// Name of client + /// A provider associated with the given domain, if domain is empty or doesn't /// have a corresponding provider the default provider will be returned - public FeatureProvider GetProvider(string clientName) + public FeatureProvider GetProvider(string domain) { - return this._repository.GetProvider(clientName); + return this._repository.GetProvider(domain); } /// @@ -104,12 +104,12 @@ public FeatureProvider GetProvider(string clientName) public Metadata? GetProviderMetadata() => this.GetProvider().GetMetadata(); /// - /// Gets providers metadata assigned to the given clientName. If the clientName has no provider + /// Gets providers metadata assigned to the given domain. If the domain has no provider /// assigned to it the default provider will be returned /// - /// Name of client + /// Name of client /// Metadata assigned to provider - public Metadata? GetProviderMetadata(string clientName) => this.GetProvider(clientName).GetMetadata(); + public Metadata? GetProviderMetadata(string domain) => this.GetProvider(domain).GetMetadata(); /// /// Create a new instance of using the current provider diff --git a/src/OpenFeature/ProviderRepository.cs b/src/OpenFeature/ProviderRepository.cs index 760503b6..49f1de43 100644 --- a/src/OpenFeature/ProviderRepository.cs +++ b/src/OpenFeature/ProviderRepository.cs @@ -127,7 +127,7 @@ private static async Task InitProviderAsync( /// /// Set a named provider /// - /// the name to associate with the provider + /// an identifier which logically binds clients with providers /// the provider to set as the default, passing null has no effect /// the context to initialize the provider with /// @@ -138,15 +138,15 @@ private static async Task InitProviderAsync( /// initialization /// /// The to cancel any async side effects. - public async Task SetProviderAsync(string? clientName, + public async Task SetProviderAsync(string? domain, FeatureProvider? featureProvider, EvaluationContext context, Func? afterInitSuccess = null, Func? afterInitError = null, CancellationToken cancellationToken = default) { - // Cannot set a provider for a null clientName. - if (clientName == null) + // Cannot set a provider for a null domain. + if (domain == null) { return; } @@ -155,17 +155,17 @@ public async Task SetProviderAsync(string? clientName, try { - this._featureProviders.TryGetValue(clientName, out var oldProvider); + this._featureProviders.TryGetValue(domain, out var oldProvider); if (featureProvider != null) { - this._featureProviders.AddOrUpdate(clientName, featureProvider, + this._featureProviders.AddOrUpdate(domain, featureProvider, (key, current) => featureProvider); } else { // If names of clients are programmatic, then setting the provider to null could result // in unbounded growth of the collection. - this._featureProviders.TryRemove(clientName, out _); + this._featureProviders.TryRemove(domain, out _); } // We want to allow shutdown to happen concurrently with initialization, and the caller to not @@ -238,22 +238,22 @@ public FeatureProvider GetProvider() } } - public FeatureProvider GetProvider(string? clientName) + public FeatureProvider GetProvider(string? domain) { #if NET6_0_OR_GREATER - if (string.IsNullOrEmpty(clientName)) + if (string.IsNullOrEmpty(domain)) { return this.GetProvider(); } #else // This is a workaround for the issue in .NET Framework where string.IsNullOrEmpty is not nullable compatible. - if (clientName == null || string.IsNullOrEmpty(clientName)) + if (domain == null || string.IsNullOrEmpty(domain)) { return this.GetProvider(); } #endif - return this._featureProviders.TryGetValue(clientName, out var featureProvider) + return this._featureProviders.TryGetValue(domain, out var featureProvider) ? featureProvider : this.GetProvider(); } diff --git a/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs b/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs index 3796821e..03650144 100644 --- a/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs +++ b/test/OpenFeature.Benchmarks/OpenFeatureClientBenchmarks.cs @@ -16,7 +16,7 @@ namespace OpenFeature.Benchmark [SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task")] public class OpenFeatureClientBenchmarks { - private readonly string _clientName; + private readonly string _domain; private readonly string _clientVersion; private readonly string _flagName; private readonly bool _defaultBoolValue; @@ -30,7 +30,7 @@ public class OpenFeatureClientBenchmarks public OpenFeatureClientBenchmarks() { var fixture = new Fixture(); - this._clientName = fixture.Create(); + this._domain = fixture.Create(); this._clientVersion = fixture.Create(); this._flagName = fixture.Create(); this._defaultBoolValue = fixture.Create(); @@ -40,7 +40,7 @@ public OpenFeatureClientBenchmarks() this._defaultStructureValue = fixture.Create(); this._emptyFlagOptions = new FlagEvaluationOptions(ImmutableList.Empty, ImmutableDictionary.Empty); - this._client = Api.Instance.GetClient(this._clientName, this._clientVersion); + this._client = Api.Instance.GetClient(this._domain, this._clientVersion); } [Benchmark] diff --git a/test/OpenFeature.Tests/OpenFeatureClientTests.cs b/test/OpenFeature.Tests/OpenFeatureClientTests.cs index d1a91c1f..ce3e9e93 100644 --- a/test/OpenFeature.Tests/OpenFeatureClientTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureClientTests.cs @@ -27,13 +27,13 @@ public class OpenFeatureClientTests : ClearOpenFeatureInstanceFixture public void OpenFeatureClient_Should_Allow_Hooks() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var hook1 = Substitute.For(); var hook2 = Substitute.For(); var hook3 = Substitute.For(); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); client.AddHooks(new[] { hook1, hook2 }); @@ -53,11 +53,11 @@ public void OpenFeatureClient_Should_Allow_Hooks() public void OpenFeatureClient_Metadata_Should_Have_Name() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); - client.GetMetadata().Name.Should().Be(clientName); + client.GetMetadata().Name.Should().Be(domain); client.GetMetadata().Version.Should().Be(clientVersion); } @@ -68,7 +68,7 @@ public void OpenFeatureClient_Metadata_Should_Have_Name() public async Task OpenFeatureClient_Should_Allow_Flag_Evaluation() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultBoolValue = fixture.Create(); @@ -79,7 +79,7 @@ public async Task OpenFeatureClient_Should_Allow_Flag_Evaluation() var emptyFlagOptions = new FlagEvaluationOptions(ImmutableList.Empty, ImmutableDictionary.Empty); await Api.Instance.SetProviderAsync(new NoOpFeatureProvider()); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); (await client.GetBooleanValueAsync(flagName, defaultBoolValue)).Should().Be(defaultBoolValue); (await client.GetBooleanValueAsync(flagName, defaultBoolValue, EvaluationContext.Empty)).Should().Be(defaultBoolValue); @@ -114,7 +114,7 @@ public async Task OpenFeatureClient_Should_Allow_Flag_Evaluation() public async Task OpenFeatureClient_Should_Allow_Details_Flag_Evaluation() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultBoolValue = fixture.Create(); @@ -125,7 +125,7 @@ public async Task OpenFeatureClient_Should_Allow_Details_Flag_Evaluation() var emptyFlagOptions = new FlagEvaluationOptions(ImmutableList.Empty, ImmutableDictionary.Empty); await Api.Instance.SetProviderAsync(new NoOpFeatureProvider()); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); var boolFlagEvaluationDetails = new FlagEvaluationDetails(flagName, defaultBoolValue, ErrorType.None, NoOpProvider.ReasonNoOp, NoOpProvider.Variant); (await client.GetBooleanDetailsAsync(flagName, defaultBoolValue)).Should().BeEquivalentTo(boolFlagEvaluationDetails); @@ -163,7 +163,7 @@ public async Task OpenFeatureClient_Should_Allow_Details_Flag_Evaluation() public async Task OpenFeatureClient_Should_Return_DefaultValue_When_Type_Mismatch() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -176,7 +176,7 @@ public async Task OpenFeatureClient_Should_Return_DefaultValue_When_Type_Mismatc mockedFeatureProvider.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(mockedFeatureProvider); - var client = Api.Instance.GetClient(clientName, clientVersion, mockedLogger); + var client = Api.Instance.GetClient(domain, clientVersion, mockedLogger); var evaluationDetails = await client.GetObjectDetailsAsync(flagName, defaultValue); evaluationDetails.ErrorType.Should().Be(ErrorType.TypeMismatch); @@ -277,7 +277,7 @@ public async Task Must_Short_Circuit_Fatal() public async Task Should_Resolve_BooleanValue() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -288,7 +288,7 @@ public async Task Should_Resolve_BooleanValue() featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); (await client.GetBooleanValueAsync(flagName, defaultValue)).Should().Be(defaultValue); @@ -299,7 +299,7 @@ public async Task Should_Resolve_BooleanValue() public async Task Should_Resolve_StringValue() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -310,7 +310,7 @@ public async Task Should_Resolve_StringValue() featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); (await client.GetStringValueAsync(flagName, defaultValue)).Should().Be(defaultValue); @@ -321,7 +321,7 @@ public async Task Should_Resolve_StringValue() public async Task Should_Resolve_IntegerValue() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -332,7 +332,7 @@ public async Task Should_Resolve_IntegerValue() featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); (await client.GetIntegerValueAsync(flagName, defaultValue)).Should().Be(defaultValue); @@ -343,7 +343,7 @@ public async Task Should_Resolve_IntegerValue() public async Task Should_Resolve_DoubleValue() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -354,7 +354,7 @@ public async Task Should_Resolve_DoubleValue() featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); (await client.GetDoubleValueAsync(flagName, defaultValue)).Should().Be(defaultValue); @@ -365,7 +365,7 @@ public async Task Should_Resolve_DoubleValue() public async Task Should_Resolve_StructureValue() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -376,7 +376,7 @@ public async Task Should_Resolve_StructureValue() featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); (await client.GetObjectValueAsync(flagName, defaultValue)).Should().Be(defaultValue); @@ -387,7 +387,7 @@ public async Task Should_Resolve_StructureValue() public async Task When_Error_Is_Returned_From_Provider_Should_Return_Error() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -399,7 +399,7 @@ public async Task When_Error_Is_Returned_From_Provider_Should_Return_Error() featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); var response = await client.GetObjectDetailsAsync(flagName, defaultValue); response.ErrorType.Should().Be(ErrorType.ParseError); @@ -412,7 +412,7 @@ public async Task When_Error_Is_Returned_From_Provider_Should_Return_Error() public async Task When_Exception_Occurs_During_Evaluation_Should_Return_Error() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -424,7 +424,7 @@ public async Task When_Exception_Occurs_During_Evaluation_Should_Return_Error() featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); await Api.Instance.SetProviderAsync(featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); var response = await client.GetObjectDetailsAsync(flagName, defaultValue); response.ErrorType.Should().Be(ErrorType.ParseError); @@ -437,7 +437,7 @@ public async Task When_Exception_Occurs_During_Evaluation_Should_Return_Error() public async Task Cancellation_Token_Added_Is_Passed_To_Provider() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultString = fixture.Create(); @@ -459,8 +459,8 @@ public async Task Cancellation_Token_Added_Is_Passed_To_Provider() featureProviderMock.GetMetadata().Returns(new Metadata(fixture.Create())); featureProviderMock.GetProviderHooks().Returns(ImmutableList.Empty); - await Api.Instance.SetProviderAsync(clientName, featureProviderMock); - var client = Api.Instance.GetClient(clientName, clientVersion); + await Api.Instance.SetProviderAsync(domain, featureProviderMock); + var client = Api.Instance.GetClient(domain, clientVersion); var task = client.GetStringDetailsAsync(flagName, defaultString, EvaluationContext.Empty, null, cts.Token); cts.Cancel(); // cancel before awaiting @@ -474,11 +474,11 @@ public async Task Cancellation_Token_Added_Is_Passed_To_Provider() public void Should_Get_And_Set_Context() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var KEY = "key"; var VAL = 1; - FeatureClient client = Api.Instance.GetClient(clientName, clientVersion); + FeatureClient client = Api.Instance.GetClient(domain, clientVersion); client.SetContext(new EvaluationContextBuilder().Set(KEY, VAL).Build()); Assert.Equal(VAL, client.GetContext().GetValue(KEY).AsInteger); } diff --git a/test/OpenFeature.Tests/OpenFeatureEventTests.cs b/test/OpenFeature.Tests/OpenFeatureEventTests.cs index a7bcd2e7..a4b0d111 100644 --- a/test/OpenFeature.Tests/OpenFeatureEventTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureEventTests.cs @@ -304,9 +304,9 @@ public async Task Client_Level_Event_Handlers_Should_Be_Registered() var fixture = new Fixture(); var eventHandler = Substitute.For(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); - var myClient = Api.Instance.GetClient(clientName, clientVersion); + var myClient = Api.Instance.GetClient(domain, clientVersion); var testProvider = new TestProvider(); await Api.Instance.SetProviderAsync(myClient.GetMetadata().Name!, testProvider); @@ -332,9 +332,9 @@ public async Task Client_Level_Event_Handlers_Should_Be_Executed_When_Other_Hand failingEventHandler.When(x => x.Invoke(Arg.Any())) .Do(x => throw new Exception()); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); - var myClient = Api.Instance.GetClient(clientName, clientVersion); + var myClient = Api.Instance.GetClient(domain, clientVersion); myClient.AddHandler(ProviderEventTypes.ProviderReady, failingEventHandler); myClient.AddHandler(ProviderEventTypes.ProviderReady, eventHandler); diff --git a/test/OpenFeature.Tests/OpenFeatureHookTests.cs b/test/OpenFeature.Tests/OpenFeatureHookTests.cs index 9ca5b364..cc8b08a1 100644 --- a/test/OpenFeature.Tests/OpenFeatureHookTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureHookTests.cs @@ -27,7 +27,7 @@ public class OpenFeatureHookTests : ClearOpenFeatureInstanceFixture public async Task Hooks_Should_Be_Called_In_Order() { var fixture = new Fixture(); - var clientName = fixture.Create(); + var domain = fixture.Create(); var clientVersion = fixture.Create(); var flagName = fixture.Create(); var defaultValue = fixture.Create(); @@ -54,7 +54,7 @@ public async Task Hooks_Should_Be_Called_In_Order() testProvider.AddHook(providerHook); Api.Instance.AddHooks(apiHook); await Api.Instance.SetProviderAsync(testProvider); - var client = Api.Instance.GetClient(clientName, clientVersion); + var client = Api.Instance.GetClient(domain, clientVersion); client.AddHooks(clientHook); await client.GetBooleanValueAsync(flagName, defaultValue, EvaluationContext.Empty, diff --git a/test/OpenFeature.Tests/OpenFeatureTests.cs b/test/OpenFeature.Tests/OpenFeatureTests.cs index 2f778ada..acc53b61 100644 --- a/test/OpenFeature.Tests/OpenFeatureTests.cs +++ b/test/OpenFeature.Tests/OpenFeatureTests.cs @@ -101,10 +101,10 @@ public async Task OpenFeature_Should_Not_Change_Named_Providers_When_Setting_Def await openFeature.SetProviderAsync(TestProvider.DefaultName, new TestProvider()); var defaultClient = openFeature.GetProviderMetadata(); - var namedClient = openFeature.GetProviderMetadata(TestProvider.DefaultName); + var domainScopedClient = openFeature.GetProviderMetadata(TestProvider.DefaultName); defaultClient?.Name.Should().Be(NoOpProvider.NoOpProviderName); - namedClient?.Name.Should().Be(TestProvider.DefaultName); + domainScopedClient?.Name.Should().Be(TestProvider.DefaultName); } [Fact] From 18368e067b1d8c6541f1db6cb5a73025177dc531 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Tue, 13 Aug 2024 11:41:39 -0400 Subject: [PATCH 2/3] Update src/OpenFeature/Api.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: AndrΓ© Silva <2493377+askpt@users.noreply.github.com> Signed-off-by: Todd Baert --- src/OpenFeature/Api.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenFeature/Api.cs b/src/OpenFeature/Api.cs index 821567b5..69b7e15c 100644 --- a/src/OpenFeature/Api.cs +++ b/src/OpenFeature/Api.cs @@ -84,7 +84,8 @@ public FeatureProvider GetProvider() /// /// Gets the feature provider with given domain /// - /// Name of client + /// An identifier which logically binds clients with providers + /// A provider associated with the given domain, if domain is empty or doesn't /// have a corresponding provider the default provider will be returned public FeatureProvider GetProvider(string domain) From 51a30046041e7c7457f63a3ff2538450faba8b3f Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Tue, 13 Aug 2024 11:41:43 -0400 Subject: [PATCH 3/3] Update src/OpenFeature/Api.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: AndrΓ© Silva <2493377+askpt@users.noreply.github.com> Signed-off-by: Todd Baert --- src/OpenFeature/Api.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenFeature/Api.cs b/src/OpenFeature/Api.cs index 69b7e15c..fae9916b 100644 --- a/src/OpenFeature/Api.cs +++ b/src/OpenFeature/Api.cs @@ -108,7 +108,8 @@ public FeatureProvider GetProvider(string domain) /// Gets providers metadata assigned to the given domain. If the domain has no provider /// assigned to it the default provider will be returned /// - /// Name of client + /// An identifier which logically binds clients with providers + /// Metadata assigned to provider public Metadata? GetProviderMetadata(string domain) => this.GetProvider(domain).GetMetadata();