Module: LaunchDarkly::Interfaces::DataSource::UpdateSink
- Included in:
- LaunchDarkly::Impl::DataSource::UpdateSink
- Defined in:
- lib/ldclient-rb/interfaces.rb
Overview
Interface that a data source implementation will use to push data into the SDK.
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.
Instance Method Summary collapse
-
#delete(kind, key, version) ⇒ void
Attempt to delete an entity if it exists.
-
#init(all_data) ⇒ void
Initializes (or re-initializes) the store with the specified set of entities.
-
#update_status(new_state, new_error) ⇒ Object
Informs the SDK of a change in the data source's status.
-
#upsert(kind, item) ⇒ void
Attempt to add an entity, or update an existing entity with the same key.
Instance Method Details
#delete(kind, key, version) ⇒ void
This method returns an undefined value.
Attempt to delete an entity if it exists. Deletion should only succeed if the
version
parameter is greater than the existing entity's :version
; otherwise, the
method should do nothing.
659 |
# File 'lib/ldclient-rb/interfaces.rb', line 659 def delete(kind, key, version) end |
#init(all_data) ⇒ void
This method returns an undefined value.
Initializes (or re-initializes) the store with the specified set of entities. Any existing entries will be removed. Implementations can assume that this data set is up to date-- there is no need to perform individual version comparisons between the existing objects and the supplied features.
If possible, the store should update the entire data set atomically. If that is not possible, it should iterate through the outer hash and then the inner hash using the existing iteration order of those hashes (the SDK will ensure that the items were inserted into the hashes in the correct order), storing each item, and then delete any leftover items at the very end.
636 |
# File 'lib/ldclient-rb/interfaces.rb', line 636 def init(all_data) end |
#update_status(new_state, new_error) ⇒ Object
Informs the SDK of a change in the data source's status.
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 new_state
is different from the previous state, and/or
new_error
is non-null, the SDK will start returning the new status
(adding a timestamp for the change) from StatusProvider#status, and
will trigger status change events to any registered listeners.
A special case is that if new_state is Status::INTERRUPTED, but the previous state was Status::INITIALIZING, the state will remain at Status::INITIALIZING because Status::INTERRUPTED is only meaningful after a successful startup.
681 |
# File 'lib/ldclient-rb/interfaces.rb', line 681 def update_status(new_state, new_error) end |
#upsert(kind, item) ⇒ void
This method returns an undefined value.
Attempt to add an entity, or update an existing entity with the same key. An update
should only succeed if the new item's :version
is greater than the old one;
otherwise, the method should do nothing.
647 |
# File 'lib/ldclient-rb/interfaces.rb', line 647 def upsert(kind, item) end |