Class: LaunchDarkly::Impl::DataSystem::FDv1 Private

Inherits:
Object
  • Object
show all
Includes:
LaunchDarkly::Impl::DataSystem
Defined in:
lib/ldclient-rb/impl/data_system/fdv1.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.

FDv1 wires the existing v1 data source and store behavior behind the generic DataSystem surface.

See Also:

Since:

  • 5.5.0

Constant Summary

Constants included from LaunchDarkly::Impl::DataSystem

FDV1_POLLING_ENDPOINT, FDV2_POLLING_ENDPOINT, FDV2_STREAMING_ENDPOINT, LD_ENVID_HEADER, LD_FD_FALLBACK_HEADER, STREAM_READ_TIMEOUT

Instance Method Summary collapse

Methods included from LaunchDarkly::Impl::DataSystem

fdv1_polling_payload_to_changeset, polling_payload_to_changeset

Constructor Details

#initialize(sdk_key, config) ⇒ FDv1

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.

Creates a new FDv1 data system.

Parameters:

Since:

  • 5.5.0



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
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 30

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
  )

  # Preserve the original unwrapped store to avoid nested wrappers on postfork
  original_store = @config.feature_store
  if original_store.is_a?(LaunchDarkly::Impl::FeatureStoreClientWrapper)
    original_store = original_store.instance_variable_get(:@store)
  end

  # Wrap the original data store with client wrapper (must be created before status provider)
  @store_wrapper = LaunchDarkly::Impl::FeatureStoreClientWrapper.new(
    original_store,
    @data_store_update_sink,
    @config.logger
  )

  # Update config to use wrapped store so data sources can access it
  @config.instance_variable_set(:@feature_store, @store_wrapper)

  # 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_availabilitySymbol

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

Returns:

Since:

  • 5.5.0



130
131
132
133
134
135
136
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 130

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_providerLaunchDarkly::Interfaces::DataSource::StatusProvider

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



110
111
112
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 110

def data_source_status_provider
  @data_source_status_provider
end

#data_store_status_providerLaunchDarkly::Interfaces::DataStore::StatusProvider

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



115
116
117
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 115

def data_store_status_provider
  @data_store_status_provider
end

#flag_change_broadcasterLaunchDarkly::Impl::Broadcaster

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 broadcaster for flag change notifications.

Consumers can use this broadcaster to build their own flag tracker or listen for flag changes directly.

Returns:

Since:

  • 5.5.0



120
121
122
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 120

def flag_change_broadcaster
  @flag_change_broadcaster
end

#set_diagnostic_accumulator(diagnostic_accumulator) ⇒ 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.

Sets the diagnostic accumulator for streaming initialization metrics. This should be called before start() to ensure metrics are collected.

Parameters:

Since:

  • 5.5.0



105
106
107
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 105

def set_diagnostic_accumulator(diagnostic_accumulator)
  @diagnostic_accumulator = diagnostic_accumulator
end

#startConcurrent::Event

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.

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.

Returns:

  • (Concurrent::Event)

    Event that will be set when initialization is complete

Since:

  • 5.5.0



87
88
89
90
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 87

def start
  @update_processor ||= make_update_processor
  @update_processor.start
end

#stopvoid

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.

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.

Since:

  • 5.5.0



93
94
95
96
97
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 93

def stop
  @update_processor&.stop
  @store_wrapper.stop
  @shared_executor.shutdown
end

#storeObject

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 data store used by the data system.

Returns:

  • (Object)

    The read-only store

Since:

  • 5.5.0



100
101
102
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 100

def store
  @store_wrapper
end

#target_availabilitySymbol

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 the ideal form of data attainable given the current configuration.

Returns:

  • (Symbol)

    one of the #DataAvailability constants

Since:

  • 5.5.0



139
140
141
142
143
# File 'lib/ldclient-rb/impl/data_system/fdv1.rb', line 139

def target_availability
  return DataAvailability::DEFAULTS if @config.offline?

  DataAvailability::REFRESHED
end