public interface DataStoreStatusProvider
An implementation of this interface is returned by LDClientInterface.getDataStoreStatusProvider()
.
Application code should not implement this interface.
Modifier and Type | Interface and Description |
---|---|
static class |
DataStoreStatusProvider.CacheStats
A snapshot of cache statistics.
|
static class |
DataStoreStatusProvider.Status
Information about a status change.
|
static interface |
DataStoreStatusProvider.StatusListener
Interface for receiving status change notifications.
|
Modifier and Type | Method and Description |
---|---|
void |
addStatusListener(DataStoreStatusProvider.StatusListener listener)
Subscribes for notifications of status changes.
|
DataStoreStatusProvider.CacheStats |
getCacheStats()
Queries the current cache statistics, if this is a persistent store with caching enabled.
|
DataStoreStatusProvider.Status |
getStatus()
Returns the current status of the store.
|
boolean |
isStatusMonitoringEnabled()
Indicates whether the current data store implementation supports status monitoring.
|
void |
removeStatusListener(DataStoreStatusProvider.StatusListener listener)
Unsubscribes from notifications of status changes.
|
DataStoreStatusProvider.Status getStatus()
This is only meaningful for persistent stores, or any custom data store implementation that makes use of the status reporting mechanism provided by the SDK. For the default in-memory store, the status will always be reported as "available".
boolean isStatusMonitoringEnabled()
This is normally true for all persistent data stores, and false for the default in-memory store. A true value
means that any listeners added with addStatusListener(StatusListener)
can expect to be notified if
there is any error in storing data, and then notified again when the error condition is resolved. A false
value means that the status is not meaningful and listeners should not expect to be notified.
void addStatusListener(DataStoreStatusProvider.StatusListener listener)
Applications may wish to know if there is an outage in a persistent data store, since that could mean that flag evaluations are unable to get the flag data from the store (unless it is currently cached) and therefore might return default values.
If the SDK receives an exception while trying to query or update the data store, then it notifies listeners
that the store appears to be offline (DataStoreStatusProvider.Status.isAvailable()
is false) and begins polling the store
at intervals until a query succeeds. Once it succeeds, it notifies listeners again with DataStoreStatusProvider.Status.isAvailable()
set to true.
This method has no effect if the data store implementation does not support status tracking, such as if you are using the default in-memory store rather than a persistent store.
listener
- the listener to addvoid removeStatusListener(DataStoreStatusProvider.StatusListener listener)
This method has no effect if the data store implementation does not support status tracking, such as if you are using the default in-memory store rather than a persistent store.
listener
- the listener to remove; if no such listener was added, this does nothingDataStoreStatusProvider.CacheStats getCacheStats()
This method returns null if the data store implementation does not support cache statistics because it is
not a persistent store, or because you did not enable cache monitoring with
PersistentDataStoreBuilder.recordCacheStats(boolean)
.
DataStoreStatusProvider.CacheStats
instance; null if not applicable