feat!: re-design No-op Provider#56
Merged
sheepduke merged 4 commits intoopen-feature:mainfrom Jan 11, 2024
Merged
Conversation
Signed-off-by: YUE Daian <sheepduke@gmail.com>
Member
|
I am adding @gruebel because he expressed interest in getting involved with the Rust SDK. |
justinabrahms
approved these changes
Jan 9, 2024
Member
|
@sheepduke is the basic usage example on the readme still accurate? If I understand correctly, the fallback value is defined using |
Co-authored-by: Justin Abrahms <justin@abrah.ms> Signed-off-by: YUE Daian <sheepduke@users.noreply.github.com>
Signed-off-by: YUE Daian <sheepduke@gmail.com>
Contributor
Author
Oh!!!! My apologies. Added it. Really appreciate your reminder! |
beeme1mr
approved these changes
Jan 10, 2024
Signed-off-by: Daian YUE 🐏 <daiyue@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR
NoOpProvider.EvaluationErrorwithProviderNotReadycode.EvaluationContextetc.mockalldependency to mockFeatureProvidertrait.TypedBuilder.EvaluationContext.=> Since every field is optional so just use
EvaluationContext::default().with_xx()to make it more unified.lib.rsto build pipeline. => Better DX.Related Issues
Notes
The main purpose of changing
NoOpProvideris to make it more compliant with the spec. The spec mentioned that:In Rust we leverage the type system to model this, instead of letting user provide a default value upon function invocation. When the flag evaluation fails due to any reason, an EvaluationError is returned, and the caller can do something like
client.get_i32_value("flag_key", &context, None).unwrap_or(100)to provide a default value.Now the
NoOpProviderreturns the default value of each data type if not configured. This is actually incorrect because theunwrap_or(..)part will never be executed (because it is alwaysOk) and the caller cannot chain a default value then.Follow-up Tasks
How to test