public interface DataSourceUpdates
The data source interacts with this object, rather than manipulating the data store directly, so that the SDK can perform any other necessary operations that must happen when data is updated.
Modifier and Type | Method and Description |
---|---|
DataStoreStatusProvider |
getDataStoreStatusProvider()
Returns an object that provides status tracking for the data store, if applicable.
|
boolean |
init(DataStoreTypes.FullDataSet<DataStoreTypes.ItemDescriptor> allData)
Completely overwrites the current contents of the data store with a set of items for each collection.
|
void |
updateStatus(DataSourceStatusProvider.State newState,
DataSourceStatusProvider.ErrorInfo newError)
Informs the SDK of a change in the data source's status.
|
boolean |
upsert(DataStoreTypes.DataKind kind,
java.lang.String key,
DataStoreTypes.ItemDescriptor item)
Updates or inserts an item in the specified collection.
|
boolean init(DataStoreTypes.FullDataSet<DataStoreTypes.ItemDescriptor> allData)
If the underlying data store throws an error during this operation, the SDK will catch it, log it,
and set the data source state to DataSourceStatusProvider.State.INTERRUPTED
with an error of
DataSourceStatusProvider.ErrorKind.STORE_ERROR
. It will not rethrow the error to the data
source, but will simply return false
to indicate that the operation failed.
allData
- a list of DataStoreTypes.DataKind
instances and their corresponding data setsboolean upsert(DataStoreTypes.DataKind kind, java.lang.String key, DataStoreTypes.ItemDescriptor item)
To mark an item as deleted, pass an DataStoreTypes.ItemDescriptor
that contains a null, with a version
number (you may use DataStoreTypes.ItemDescriptor.deletedItem(int)
). Deletions must be versioned so that
they do not overwrite a later update in case updates are received out of order.
If the underlying data store throws an error during this operation, the SDK will catch it, log it,
and set the data source state to DataSourceStatusProvider.State.INTERRUPTED
with an error of
DataSourceStatusProvider.ErrorKind.STORE_ERROR
. It will not rethrow the error to the data
source, but will simply return false
to indicate that the operation failed.
kind
- specifies which collection to usekey
- the unique key for the item within that collectionitem
- the item to insert or updateDataStoreStatusProvider getDataStoreStatusProvider()
This may be useful if the data source needs to be aware of storage problems that might require it to take some special action: for instance, if a database outage may have caused some data to be lost and therefore the data should be re-requested from LaunchDarkly.
DataStoreStatusProvider
void updateStatus(DataSourceStatusProvider.State newState, DataSourceStatusProvider.ErrorInfo newError)
Data source implementations should use this method if they have any concept of being in a valid state, a temporarily disconnected state, or a permanently stopped state.
If newState
is different from the previous state, and/or newError
is non-null, the
SDK will start returning the new status (adding a timestamp for the change) from
DataSourceStatusProvider.getStatus()
, and will trigger status change events to any
registered listeners.
A special case is that if newState
is DataSourceStatusProvider.State.INTERRUPTED
,
but the previous state was DataSourceStatusProvider.State.INITIALIZING
, the state will remain
at DataSourceStatusProvider.State.INITIALIZING
because DataSourceStatusProvider.State.INTERRUPTED
is only meaningful after a successful startup.
newState
- the data source statenewError
- information about a new error, if anyDataSourceStatusProvider