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: Support for name client to given provider #129

Merged
merged 1 commit into from
May 31, 2023

Conversation

benjiro
Copy link
Member

@benjiro benjiro commented May 27, 2023

This PR

Adds support for mapping name clients to a given provider.

  • Preserves backward compatibility with existing clients

Related Issues

Refs: Refs open-feature/ofep#56
Fixes: #131

Notes

N/A

Follow-up Tasks

  • Update documentation

How to test

Testing is covered by the unit tests added in the PR

@benjiro benjiro force-pushed the feat/ofep-56-named-client branch from 8e25966 to 632929c Compare May 27, 2023 12:45
@codecov
Copy link

codecov bot commented May 27, 2023

Codecov Report

Merging #129 (abaea88) into main (9152d63) will increase coverage by 0.10%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     open-feature/dotnet-sdk#129      +/-   ##
==========================================
+ Coverage   94.54%   94.64%   +0.10%     
==========================================
  Files          20       20              
  Lines         532      542      +10     
  Branches       37       39       +2     
==========================================
+ Hits          503      513      +10     
  Misses         16       16              
  Partials       13       13              
Impacted Files Coverage Δ
src/OpenFeature/Api.cs 100.00% <100.00%> (ø)
src/OpenFeature/OpenFeatureClient.cs 98.70% <100.00%> (-0.05%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@benjiro benjiro force-pushed the feat/ofep-56-named-client branch from 632929c to ce4f654 Compare May 29, 2023 10:49
@benjiro benjiro marked this pull request as ready for review May 29, 2023 10:53
@benjiro benjiro requested a review from a team as a code owner May 29, 2023 10:53
@@ -21,7 +21,49 @@ public void OpenFeature_Should_Be_Singleton()
}

[Fact]
[Specification("1.1.3", "The `API` MUST provide a function to add `hooks` which accepts one or more API-conformant `hooks`, and appends them to the collection of any previously added hooks. When new hooks are added, previously added hooks are not removed.")]
[Specification("1.1.3", "The `API` MUST provide a function to bind a given `provider` to one or more client `name`s. If the client-name already has a bound provider, it is overwritten with the new mapping.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about the "or more client names." part of this.

Which implies to me:

var provider = new TestProvider();

openFeature.SetProvider("a", provider);
openFeature.SetProvider("b", provider);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Which will need more consideration with init/shutdown potentially.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have concerns with mapping the same provider instance to 2 names? What's the risk you see here? Maybe we need to spec something additional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@toddbaert

Basic case.

var provider1 = new TestProvider();

openFeature.SetProvider("a",  provider1);

// Call init on provider1?

openFeature.SetProvider("a",  new TestProvider());

// Call shutdown on provider 1?

// Call init on new provider.

Two Names Scenario 1.

var provider = new TestProvider();

openFeature.SetProvider("a", provider);

// Call init on provider?

openFeature.SetProvider("b", provider);

// Provider already has init called. Do we call it again?

Two Names Scenario 2.

var provider1 = new TestProvider();

openFeature.SetProvider("a", provider1);
openFeature.SetProvider("b", provider1);

openFeature.SetProvider("b",  new TestProvider());

// We don't want to shutdown provider1, because it is still registered to "b".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this scenario to the tests cases.

This is an interesting thought about the init/shutdown, I haven't yet had a look at the spec for it but I would think it only calls shutdown if there are zero references to the object. I'll create a issue for this and lets continue the discussion under that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@kinyoklion kinyoklion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with comment on test.

@toddbaert
Copy link
Member

@benjiro I hope you don't mind, I created a new standalone issue and linked it so that the whole 0.6.0 issue isn't closed.

Signed-off-by: Benjamin Evenson <2031163+benjiro@users.noreply.github.com>
@benjiro benjiro force-pushed the feat/ofep-56-named-client branch from ce4f654 to abaea88 Compare May 31, 2023 11:13
@benjiro benjiro merged commit 3f765c6 into main May 31, 2023
11 checks passed
@toddbaert toddbaert deleted the feat/ofep-56-named-client branch June 12, 2023 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement named client support: open-feature/spec@4cf8229 -
3 participants