Class: LaunchDarkly::Impl::DataStore::FeatureStoreClientWrapperV2 Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::DataStore::FeatureStoreClientWrapperV2
- Includes:
- LaunchDarkly::Interfaces::FeatureStore
- Defined in:
- lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides additional behavior that the client requires before or after feature store operations. Currently this just means sorting the data set for init() and dealing with data store status listeners.
Instance Method Summary collapse
-
#all(kind) ⇒ Hash
private
Returns all stored entities of the specified kind, not including deleted entities.
-
#delete(kind, key, version) ⇒ void
private
Attempt to delete an entity if it exists.
-
#get(kind, key) ⇒ Hash
private
Returns the entity to which the specified key is mapped, if any.
-
#init(all_data) ⇒ void
private
Initializes (or re-initializes) the store with the specified set of entities.
-
#initialize(store, store_update_sink, logger) ⇒ FeatureStoreClientWrapperV2
constructor
private
Initialize the wrapper.
-
#initialized? ⇒ Boolean
private
Checks whether this store has been initialized.
-
#monitoring_enabled? ⇒ Boolean
private
Returns whether monitoring is enabled.
-
#stop ⇒ void
private
Performs any necessary cleanup to shut down the store when the client is being shut down.
-
#upsert(kind, item) ⇒ void
private
Attempt to add an entity, or update an existing entity with the same key.
Constructor Details
#initialize(store, store_update_sink, logger) ⇒ FeatureStoreClientWrapperV2
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the wrapper.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 25 def initialize(store, store_update_sink, logger) @store = store @store_update_sink = store_update_sink @logger = logger @monitoring_enabled = store_supports_monitoring? # Thread synchronization @mutex = Mutex.new @last_available = true @poller = nil @closed = false end |
Instance Method Details
#all(kind) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns all stored entities of the specified kind, not including deleted entities.
49 50 51 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 49 def all(kind) wrapper { @store.all(kind) } end |
#delete(kind, key, version) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
54 55 56 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 54 def delete(kind, key, version) wrapper { @store.delete(kind, key, version) } end |
#get(kind, key) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the entity to which the specified key is mapped, if any.
44 45 46 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 44 def get(kind, key) wrapper { @store.get(kind, key) } end |
#init(all_data) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
39 40 41 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 39 def init(all_data) wrapper { @store.init(FeatureStoreDataSetSorter.sort_all_collections(all_data)) } end |
#initialized? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks whether this store has been initialized. That means that init has been called
either by this process, or (if the store can be shared) by another process. This
method will be called frequently, so it should be efficient. You can assume that if it
has returned true once, it can continue to return true, i.e. a store cannot become
uninitialized again.
64 65 66 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 64 def initialized? @store.initialized? end |
#monitoring_enabled? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns whether monitoring is enabled.
90 91 92 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 90 def monitoring_enabled? @monitoring_enabled end |
#stop ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Performs any necessary cleanup to shut down the store when the client is being shut down.
This method should be idempotent - it is safe to call it multiple times, and subsequent calls after the first should have no effect.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 69 def stop poller_to_stop = nil @mutex.synchronize do return if @closed @closed = true poller_to_stop = @poller @poller = nil end poller_to_stop.stop if poller_to_stop @store.stop end |
#upsert(kind, item) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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.
59 60 61 |
# File 'lib/ldclient-rb/impl/data_store/feature_store_client_wrapper.rb', line 59 def upsert(kind, item) wrapper { @store.upsert(kind, item) } end |