Class: LaunchDarkly::Impl::DataSystem::FDv1
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::DataSystem::FDv1
- Includes:
- LaunchDarkly::Impl::DataSystem
- Defined in:
- lib/ldclient-rb/impl/data_system/fdv1.rb
Overview
FDv1 wires the existing v1 data source and store behavior behind the generic DataSystem surface.
Instance Method Summary collapse
-
#data_availability ⇒ Symbol
Indicates what form of data is currently available.
-
#data_source_status_provider ⇒ LaunchDarkly::Interfaces::DataSource::StatusProvider
Returns an interface for tracking the status of the data source.
-
#data_store_status_provider ⇒ LaunchDarkly::Interfaces::DataStore::StatusProvider
Returns an interface for tracking the status of a persistent data store.
-
#flag_change_broadcaster ⇒ LaunchDarkly::Impl::Broadcaster
Returns the broadcaster for flag change notifications.
-
#initialize(sdk_key, config) ⇒ FDv1
constructor
Creates a new FDv1 data system.
-
#set_diagnostic_accumulator(diagnostic_accumulator) ⇒ void
Sets the diagnostic accumulator for streaming initialization metrics.
-
#start ⇒ Concurrent::Event
Starts the data system.
-
#stop ⇒ void
Halts the data system.
-
#store ⇒ Object
Returns the data store used by the data system.
-
#target_availability ⇒ Symbol
Indicates the ideal form of data attainable given the current configuration.
Constructor Details
#initialize(sdk_key, config) ⇒ FDv1
Creates a new FDv1 data system.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 27 def initialize(sdk_key, config) @sdk_key = sdk_key @config = config @shared_executor = Concurrent::SingleThreadExecutor.new # Set up data store plumbing @data_store_broadcaster = LaunchDarkly::Impl::Broadcaster.new(@shared_executor, @config.logger) @data_store_update_sink = LaunchDarkly::Impl::DataStore::UpdateSink.new( @data_store_broadcaster ) # Wrap the data store with client wrapper (must be created before status provider) @store_wrapper = LaunchDarkly::Impl::FeatureStoreClientWrapper.new( @config.feature_store, @data_store_update_sink, @config.logger ) # Create status provider with store wrapper @data_store_status_provider = LaunchDarkly::Impl::DataStore::StatusProvider.new( @store_wrapper, @data_store_update_sink ) # Set up data source plumbing @data_source_broadcaster = LaunchDarkly::Impl::Broadcaster.new(@shared_executor, @config.logger) @flag_change_broadcaster = LaunchDarkly::Impl::Broadcaster.new(@shared_executor, @config.logger) @data_source_update_sink = LaunchDarkly::Impl::DataSource::UpdateSink.new( @store_wrapper, @data_source_broadcaster, @flag_change_broadcaster ) @data_source_status_provider = LaunchDarkly::Impl::DataSource::StatusProvider.new( @data_source_broadcaster, @data_source_update_sink ) # Ensure v1 processors can find the sink via config for status updates @config.data_source_update_sink = @data_source_update_sink # Update processor created in start() @update_processor = nil # Diagnostic accumulator provided by client for streaming metrics @diagnostic_accumulator = nil end |
Instance Method Details
#data_availability ⇒ Symbol
Indicates what form of data is currently available.
This is calculated dynamically based on current system state.
In LDD mode, always returns CACHED for backwards compatibility, even if the store is empty.
117 118 119 120 121 122 123 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 117 def data_availability return DataAvailability::DEFAULTS if @config.offline? return DataAvailability::REFRESHED if @update_processor && @update_processor.initialized? return DataAvailability::CACHED if @store_wrapper.initialized? DataAvailability::DEFAULTS end |
#data_source_status_provider ⇒ LaunchDarkly::Interfaces::DataSource::StatusProvider
Returns an interface for tracking the status of the data source.
The data source is the mechanism that the SDK uses to get feature flag configurations, such as a streaming connection (the default) or poll requests.
97 98 99 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 97 def data_source_status_provider @data_source_status_provider end |
#data_store_status_provider ⇒ LaunchDarkly::Interfaces::DataStore::StatusProvider
Returns an interface for tracking the status of a persistent data store.
The provider has methods for checking whether the data store is (as far as the SDK knows) currently operational, tracking changes in this status, and getting cache statistics. These are only relevant for a persistent data store; if you are using an in-memory data store, then this method will return a stub object that provides no information.
102 103 104 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 102 def data_store_status_provider @data_store_status_provider end |
#flag_change_broadcaster ⇒ LaunchDarkly::Impl::Broadcaster
Returns the broadcaster for flag change notifications.
Consumers can use this broadcaster to build their own flag tracker or listen for flag changes directly.
107 108 109 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 107 def flag_change_broadcaster @flag_change_broadcaster end |
#set_diagnostic_accumulator(diagnostic_accumulator) ⇒ void
This method returns an undefined value.
Sets the diagnostic accumulator for streaming initialization metrics. This should be called before start() to ensure metrics are collected.
92 93 94 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 92 def set_diagnostic_accumulator(diagnostic_accumulator) @diagnostic_accumulator = diagnostic_accumulator end |
#start ⇒ Concurrent::Event
Starts the data system.
This method will return immediately. The returned event will be set when the system has reached an initial state (either permanently failed, e.g. due to bad auth, or succeeded).
If called multiple times, returns the same event as the first call.
75 76 77 78 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 75 def start @update_processor ||= make_update_processor @update_processor.start end |
#stop ⇒ void
This method returns an undefined value.
Halts the data system. Should be called when the client is closed to stop any long running operations. Makes the data system no longer usable.
81 82 83 84 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 81 def stop @update_processor&.stop @shared_executor.shutdown end |
#store ⇒ Object
Returns the data store used by the data system.
87 88 89 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 87 def store @store_wrapper end |
#target_availability ⇒ Symbol
Indicates the ideal form of data attainable given the current configuration.
126 127 128 129 130 |
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 126 def target_availability return DataAvailability::DEFAULTS if @config.offline? DataAvailability::REFRESHED end |