Class: LaunchDarkly::Impl::DataStore::StatusProviderV2 Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
LaunchDarkly::Interfaces::DataStore::StatusProvider
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.

Since:

  • 5.5.0

Instance Method Summary collapse

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.

Parameters:

  • store (Object, nil)

    The feature store (may be nil for in-memory only)

  • status_broadcaster (LaunchDarkly::Impl::Broadcaster)

    Broadcaster for status changes

Since:

  • 5.5.0



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.

Returns:

  • (Boolean)

    true if status monitoring is enabled

Since:

  • 5.5.0



55
56
57
# File 'lib/ldclient-rb/impl/data_store/status_provider.rb', line 55

def monitoring_enabled?
  @monitoring_enabled
end

#statusStatus

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

Returns:

  • (Status)

    the latest status

Since:

  • 5.5.0



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.

Parameters:

  • status (Status)

    the updated status properties

Since:

  • 5.5.0



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