Interface DataStoreStatusProvider


  • public interface DataStoreStatusProvider
    An interface for querying the status of a persistent data store.

    An implementation of this interface is returned by LDClientInterface.getDataStoreStatusProvider(). Application code should not implement this interface.

    Since:
    5.0.0
    • Method Detail

      • getStatus

        DataStoreStatusProvider.Status getStatus()
        Returns the current status of the store.

        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".

        Returns:
        the latest status; will never be null
      • isStatusMonitoringEnabled

        boolean isStatusMonitoringEnabled()
        Indicates whether the current data store implementation supports status monitoring.

        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.

        Returns:
        true if status monitoring is enabled
      • addStatusListener

        void addStatusListener​(DataStoreStatusProvider.StatusListener listener)
        Subscribes for notifications of status changes.

        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.

        Parameters:
        listener - the listener to add
      • removeStatusListener

        void removeStatusListener​(DataStoreStatusProvider.StatusListener listener)
        Unsubscribes from notifications of status changes.

        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.

        Parameters:
        listener - the listener to remove; if no such listener was added, this does nothing