-
Notifications
You must be signed in to change notification settings - Fork 3
Declare a Feature trait, re-implement FeatureProxy #26
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
Conversation
…ture Signed-off-by: Javier G. Sogo <[email protected]>
Signed-off-by: Javier G. Sogo <[email protected]>
pub struct FeatureProxy<'a> { | ||
client: &'a AppConfigurationClient, |
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.
This makes it evident that the feature proxy can only live as long as the client is around. See the getter:
pub fn get_feature_proxy<'a>(&'a self, feature_id: &str) -> Result<FeatureProxy<'a>>
This implementation will also let us simplify the internals of the AppConfigurationClient
... I'm not 100% sure if this will be the final API, but as long as we don't have a user requesting something different I would choose whatever is easier to implement/maintain.
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.
I like the reference here :-) How would a user use this though? is the proxy still useful?
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.
as discussed: probably like this:
{
let client = AppConfigClient::new(...);
let feature1 = client.get_feature_proxy(...);
let feature2 = client.get_feature_proxy(...);
some_sub_component_entry_point(feature1);
some_other_sub_component(feature2);
}
fn get_id(&self) -> &str; | ||
|
||
fn get_name(&self) -> Result<String>; | ||
|
||
fn get_data_type(&self) -> Result<crate::models::ValueKind>; | ||
|
||
fn is_enabled(&self) -> Result<bool>; | ||
|
||
fn get_enabled_value(&self) -> Result<crate::models::ConfigValue>; |
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.
I added these methods just because they are being used in some test or example, but I really think some of them don't belong to the API (or at least, I think we should not expose the models
). This is something to tackle in #7
} | ||
|
||
pub fn get_feature(&self, feature_id: &str) -> Result<Feature> { | ||
pub fn get_feature(&self, feature_id: &str) -> Result<FeatureSnapshot> { |
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.
do you think we should change the function name to get_feature_snapshot
too?
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.
I don't think so, but I'm not sure. Maybe we should change FeatureSnapshot
instead. Something like FeatureImpl
or similar
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.
No, I like the type name "FeatureSnapshot" :)
…roperty (#28) See #26 for details Signed-off-by: Javier G. Sogo <[email protected]>
A new
Feature
trait that is implemented by our currentFeature
andFeatureProxy
.Rename our current
Feature
toFeatureSnapshot
, to make it clear it will always return the same evaluationReimplement
FeatureProxy
making it much straightforwardwith this approach, every method can be implemented in terms of our current
Feature
: we just return a regular feature (with the configuration at that time) and call the method on it.