Class: LaunchDarkly::Impl::DataStore::StatusProviderV2 Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::DataStore::StatusProviderV2
- Extended by:
- Forwardable
- Defined in:
- lib/ldclient-rb/impl/data_store/status_provider.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.
StatusProviderV2 is the FDv2-specific implementation of LaunchDarkly::Interfaces::DataStore::StatusProvider.
Instance Method Summary collapse
-
#initialize(store, status_broadcaster) ⇒ StatusProviderV2
constructor
private
Initialize the status provider.
-
#monitoring_enabled? ⇒ Boolean
private
Indicates whether the current data store implementation supports status monitoring.
-
#status ⇒ Status
private
Returns the current status of the store.
-
#update_status(status) ⇒ Object
private
Reports a change in the data store’s operational status.
Methods included from LaunchDarkly::Interfaces::DataStore::StatusProvider
#add_listener, #remove_listener
Constructor Details
#initialize(store, status_broadcaster) ⇒ StatusProviderV2
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 status provider.
25 26 27 28 29 30 31 |
# File 'lib/ldclient-rb/impl/data_store/status_provider.rb', line 25 def initialize(store, status_broadcaster) @store = store @status_broadcaster = status_broadcaster @lock = Concurrent::ReadWriteLock.new @status = LaunchDarkly::Interfaces::DataStore::Status.new(true, false) @monitoring_enabled = store_supports_monitoring? end |
Instance Method Details
#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.
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 LaunchDarkly::Interfaces::DataStore::StatusProvider#add_listener 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.
55 56 57 |
# File 'lib/ldclient-rb/impl/data_store/status_provider.rb', line 55 def monitoring_enabled? @monitoring_enabled end |
#status ⇒ Status
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 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”.
48 49 50 51 52 |
# File 'lib/ldclient-rb/impl/data_store/status_provider.rb', line 48 def status @lock.with_read_lock do LaunchDarkly::Interfaces::DataStore::Status.new(@status.available, @status.stale) end end |
#update_status(status) ⇒ Object
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.
Reports a change in the data store’s operational status.
This is what makes the status monitoring mechanisms in LaunchDarkly::Impl::DataStore::StatusProvider work.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ldclient-rb/impl/data_store/status_provider.rb', line 34 def update_status(status) modified = false @lock.with_write_lock do if @status.available != status.available || @status.stale != status.stale @status = status modified = true end end @status_broadcaster.broadcast(status) if modified end |