-
Notifications
You must be signed in to change notification settings - Fork 10
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!: re-design No-op Provider #56
Conversation
Signed-off-by: YUE Daian <[email protected]>
I am adding @gruebel because he expressed interest in getting involved with the Rust SDK. |
@sheepduke is the basic usage example on the readme still accurate? If I understand correctly, the fallback value is defined using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work 🏅
Co-authored-by: Justin Abrahms <[email protected]> Signed-off-by: YUE Daian <[email protected]>
Signed-off-by: YUE Daian <[email protected]>
Oh!!!! My apologies. Added it. Really appreciate your reminder! |
Signed-off-by: Daian YUE 🐏 <[email protected]>
This PR
NoOpProvider
.EvaluationError
withProviderNotReady
code.EvaluationContext
etc.mockall
dependency to mockFeatureProvider
trait.TypedBuilder
.EvaluationContext
.=> Since every field is optional so just use
EvaluationContext::default().with_xx()
to make it more unified.lib.rs
to build pipeline. => Better DX.Related Issues
Notes
The main purpose of changing
NoOpProvider
is 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
NoOpProvider
returns 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