-
Notifications
You must be signed in to change notification settings - Fork 63
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
Create Class to Easily Monitor Feature Flag State Changes #341
Comments
Adding a note here that after a couple hours of letting this idea set, I don't think I like the names of the |
Hey @lannuttia, so I think some of this is really useful and some of it I want to push back gently on. We already have an event system in the client, which I think anything like this should tap into. I don't think it's unreasonable to send events when a given feature flag changes. We already send those events on the .NET and Java SDKs. So I'd rather we use a pattern like that, since we're desperately trying to maintain some consistency between our SDKs. If that was in place, I want to say what you're trying to do here would be a few lines of code for end users. Out of curiosity, how do you see this playing with usage metrics? |
I hadn't put too much thought into usage metrics to be honest. That's an interesting thing to think about though. I would think that we would want to have there be an impression per registered callback but I don't really know. As for the event system, I do not know how exactly I would hook into that in order to functionally accomplish what I accomplished above off the top of my head. I'm sure it's possible though and based on my admittedly limited understanding of this project, that does seem like the right spot for this. |
It appears that the Do you have a general idea of how the project would want functionality to be exposed? If I am understanding what you are thinking, you are thinking we allow someone to optionally provide a callback that gets called when a feature flag's state changes. That callback can then send that event using blinker or some analogous event handling mechanism or be used directly without blinker if the user doesn't need to register multiple handlers. Coming back to usage metrics, I would think about trying to use a getter for the |
Yeah I hadn't either to be honest. We could also just skip the metrics entirely for this feature
It's a bit early in the morning here but I think this makes sense. So idle thoughts but I think passing the event emitter to the fetch code, would let us fire a event if the etag is different. Then the existing event handling code can do something like this:
That would probably work but I'd suggest just moving a chunk of the @gastonfournier I know you were more or less leaving this to me but I could use a third smart brain here to thrash out the design details with us |
Is your feature request related to a problem? Please describe.
I would like to be able to use a feature flag to subscribe/unsubscribe a Kafka consumer essentially enabling or disabling consumption of messages.
Describe the solution you'd like
A solution that I think would help with this is essentially a
FeatureFlag
class that has a__init__
that takes all the same arguments as theUnleashClient
'sis_enabled
method as well as anUnleashClient
reference. This would use a context manager to hook into theUnleashClient
's scheduler and monitor for feature flag updates. On exit, the context manager could clean up the job that monitors for updates. A callback can be registered and deregistered from being ran when a feature flag's status changes with aregister
andderegister
method, respectively.Describe alternatives you've considered
For this specific use case, I can't really think of any other alternative that would work quite as well.
Additional context
I have a prototype for this feature (minus the context and fallback function) here:
I have tested this out in another project that I am working on. I think I should be able to submit a pull request that adds this and associated automated tests. I am mostly just wanting to check and make sure that this is something that the project thinks would be useful before I go and spend time creating and submitting a pull request for this.
Example Usage
The text was updated successfully, but these errors were encountered: