java-server-sdk
java-server-sdk copied to clipboard
Have a robust in memory datastore fallback when the persistent data store connection is not working
Is your feature request related to a problem? Please describe.
- Currently if I have a PersistentDataStore (like Redis) that is not reachable when initializing the LaunchDarkly client, when I try to evaluate a feature flag I will receive the defaultValue even though we did receive properly the initial state of the flags from the LaunchDarkly API.
- Also, if the PersistentDataStore is properly initilialized but connection to Redis is lost later, any update on the feature flags from LaunchDarkly won't be applied until Redis connection is back even though we did receive those updates from the LaunchDarkly api.
Describe the solution you'd like I think it'd be nice to be able to fallback on the latest known values from the LaunchDarkly api when the connection to the persistent data store is initializing or failing.
Describe alternatives you've considered
- I tried creating a custom implementation of DataStore that has both a PersistentDataStore and a InMemoryDataStore but there are some serialization logic done by PersistentDataStoreWrapper that are not exported and that I don't want to duplicate the code
- For the initialization problem I tried to configure the PersistentDataStore with an unlimited cache, but that implied that the dataStore StatusListener was not updated anymore when the connection was lost
- To solve problem 1 I ended up creating a custom implementation of DataStore that falls back on an InMemoryDatastore when the main dataStore is not initialized but it doesn't solve problem 2.