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

.NET client configuration "Update" event #149

Closed
beefo opened this issue Jun 26, 2023 · 8 comments · Fixed by #153
Closed

.NET client configuration "Update" event #149

beefo opened this issue Jun 26, 2023 · 8 comments · Fixed by #153
Assignees

Comments

@beefo
Copy link

beefo commented Jun 26, 2023

Is your feature request related to a problem? Please describe.
We are using the .NET client. There are some parts of the code which we would like to listen for configuration changes and trigger an action dynamically based on if a feature changed.

Example:
We don't use the js library, we wrap our own API method to get feature flags. We want to set up an event handler on the "update" event and send a message via existing web socket to the client to re-pull feature flag states.

Describe the solution you'd like
Add "Update" event which get's emitted every time the Unleash Proxy returns a new feature toggle configuration. Similar to js client. Perhaps even having parifty of the events.

Describe alternatives you've considered
Unleash event log with web hook. This would be a complex and round about solution on our end. We have a distributed system. We would need to set up a new service with an endpoint for Unleash event logs, have all services "in-touch" with it, and notify all clients when a feature state changes. Essentially duplicating what the Unleash client already does.

Additional context

@nunogois
Copy link
Member

Hi @beefo, thanks for opening this issue. I'll reach out to the rest of the team and hopefully we'll be able to get back to you soon.

@beefo
Copy link
Author

beefo commented Jul 26, 2023

@nunogois Just checking back to see if you and the team had a chance to consider the improvement?

@gastonfournier
Copy link

Hi @beefo I wanted to clarify and align on something. The example you linked to, is an in-process solution that's hooked to the polling cycle here:
https://github.com/Unleash/unleash-proxy-client-js/blob/3e17a44a8656012b499243a9eb0fd0218de82702/src/index.ts#L362-L384

which emits the event when features have changed:
https://github.com/Unleash/unleash-proxy-client-js/blob/3e17a44a8656012b499243a9eb0fd0218de82702/src/index.ts#L356C1-L358

We want to set up an event handler on the "update" event and send a message via existing web socket to the client to re-pull feature flag states.

I believe this will not work as you expect, because the event is triggered after the pull cycle, re-pulling the state would be unnecessary as it will be fresh. Our clients do not use web sockets to communicate with the server, they use a fetch-all request inside a poll cycle.

If that's the problem you want to solve, maybe you can look into https://docs.getunleash.io/reference/addons/webhook which can call an external HTTP endpoint when a feature is changed in the server.

If you want to communicate with multiple clients you can have a serverless function that can re-post this event to a pub/sub queue that the clients can subscribe to.

But maybe I'm going too far into the solution space without having the proper context. For sure .NET can have a similar functionality as the JS proxy, but I just want to understand better the motivation

@beefo
Copy link
Author

beefo commented Aug 1, 2023

Hi @gastonfournier thanks for getting back to me.

I think that is indeed what we want. Details of our use case aside, what the js client provides is exactly what we want in the .NET client. An event fired after the poll that tells us if any feature has been changed.

We would use this event to let our front end(s) know to pull the updated feature flag states. We are not using the Unleash js client on our front end. The implementation details of us using web sockets, etc is mostly irrelevant. I was just trying to provide as much context as possible. I think I may have rather caused some confusion.

What it boils down to is we need the .NET client to let us know when a feature has changed.

@gastonfournier
Copy link

Hi @beefo! We have this in our backlog but is not a high priority at the moment. The implementation will follow the pattern of Error Events and Impression Events, with callbacks registered on the EventCallbackConfig class (src/Unleash/Internal/EventCallbackConfig.cs) through the ConfigureEvents method on IUnleash. The event will then be raised similarly to how Error events are raised in CachedFilesLoader (src/Unleash/Internal/CachedFilesLoader.cs lines 65, 80, etc). Or if you want to contribute with a pull request we'll happily look after it

@YayBurritos
Copy link
Contributor

YayBurritos commented Aug 10, 2023

We also have an application (.net API) that could benefit from this feature. I actually started looking into it today when I came across this request. I'm planning to try this out locally (following the existing event pattern within the Unleash dotnet SDK). If I make any progress, I'd be happy to contribute.

@daveleek
Copy link
Collaborator

@beefo We have just released Unleash-Client 3.1.0 with @YayBurritos' contribution, should be up on NuGet now!

@beefo
Copy link
Author

beefo commented Aug 14, 2023

Thanks @YayBurritos @daveleek!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants