launchdarkly / openfeature-node-server

An open feature provider for the LaunchDarkly node SDK.
Other
10 stars 3 forks source link

Support for shutdown/closure of LD Client #15

Closed jakedoublev closed 10 months ago

jakedoublev commented 1 year ago

Is your feature request related to a problem? Please describe. The LaunchDarkly documentation recommends shutting down an instantiated Client whenever it is done being used: LD docs.

Right now, this implementation does not provide any shutdown functionality to OpenFeature to meet that LaunchDarkly requirement. It's a great idea to add it for many reasons:

Describe the solution you'd like A shutdown method could be added to the Provider that in turn invokes the LD SDK method client.close(). This would be very easy to add, and OpenFeature could then handle the upstream logic dependent upon a Provider with a valid and active Client. That will be on the OF side, but a simple and durable implementation would just check if the Provider is active or shut down, and handle appropriately. It can be up to OF whether or not to re-instantiate, throw an error, or some other behavior, but without the ability to shut down via the Provider first, that would not be a possible behavior decision to make.

Describe alternatives you've considered The only real alternative seems to be never allowing a shutdown of the Provider (and LD Client), but that goes against LaunchDarkly's documentation of implementation best practices, and it is the current implementation of the Provider with no shutdown or close functionality in place.

jakedoublev commented 1 year ago

Issue within OpenFeature/spec to update functionality for provision of "shutdown" functionality. Issue 163

weyert commented 1 year ago

Yeah, similar issue with PostHog that's why I worked on a spec enhancement proposal for it: https://github.com/open-feature/ofep/pull/30/files

I will push my latest updates and then you can have a look at it too :)

kinyoklion commented 1 year ago

@jakedoublev The way the LD provider works provides full access to the underlying LD Client (the app developer instantiates the client). This allows you to shutdown the client, as well as some other things not currently in the OF spec (like waiting for initialization or track events for experiments).

Once some shutdown or close mechanism is in the OF spec, and the JS OpenFeature SDK, then this provider would be updated to support it.

kinyoklion commented 10 months ago

@jakedoublev Version 0.5.0 has been released which supports a version of the open feature SDK which has support for shutdown.

jakedoublev commented 10 months ago

@kinyoklion great news! Thanks for the update and your work enabling this. :)