Class: LaunchDarkly::DataSystem::ConfigBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/data_system/config_builder.rb

Overview

Builder for the data system configuration.

This builder configures the overall data acquisition strategy for the SDK, including which data sources to use for initialization and synchronization, and how to interact with a persistent data store.

Instance Method Summary collapse

Constructor Details

#initialize ⇒ ConfigBuilder

Returns a new instance of ConfigBuilder.



20
21
22
23
24
25
26
27
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 20

def initialize
  @initializers = nil
  @synchronizers = nil
  @fdv1_fallback_synchronizer = nil
  @data_store_mode = LaunchDarkly::Interfaces::DataSystem::DataStoreMode::READ_ONLY
  @data_store = nil
  @overrides = nil
end

Instance Method Details

#build ⇒ DataSystemConfig

Builds the data system configuration.

Returns:



126
127
128
129
130
131
132
133
134
135
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 126

def build
  DataSystemConfig.new(
    initializers: @initializers,
    synchronizers: @synchronizers,
    data_store_mode: @data_store_mode,
    data_store: @data_store,
    fdv1_fallback_synchronizer: @fdv1_fallback_synchronizer,
    overrides: @overrides
  )
end

#data_store(data_store, store_mode) ⇒ ConfigBuilder

Sets the data store configuration for the data system.

Parameters:

Returns:



83
84
85
86
87
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 83

def data_store(data_store, store_mode)
  @data_store = data_store
  @data_store_mode = store_mode
  self
end

#fdv1_compatible_synchronizer(fallback) ⇒ ConfigBuilder

Configures the SDK with a fallback synchronizer that is compatible with the Flag Delivery v1 API.

This fallback is used when the server signals that the environment should revert to FDv1 protocol. Most users will not need to set this directly.

Parameters:

  • fallback (#build(String, Config)) —

    Builder that responds to build(sdk_key, config) and returns the fallback Synchronizer

Returns:



70
71
72
73
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 70

def fdv1_compatible_synchronizer(fallback)
  @fdv1_fallback_synchronizer = fallback
  self
end

#initializers(initializers) ⇒ ConfigBuilder

Sets the initializers for the data system.

Initializers are used to fetch an initial set of data when the SDK starts. They are tried in order; if the first one fails, the next is tried, and so on.

Parameters:

  • initializers (Array<#build(String, Config)>) —

    Array of builders that respond to build(sdk_key, config) and return an Initializer

Returns:



39
40
41
42
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 39

def initializers(initializers)
  @initializers = initializers
  self
end

#overrides(source) ⇒ ConfigBuilder

Configures the SDK with an override source. Flag overrides are currently experimental and subject to change.

Overrides are flag and segment definitions that take precedence over data received from LaunchDarkly at evaluation time, on a per-key basis. They exist for resilience during an incident. Overrides let an operator force one or more flags to a known state on a running client, whether or not the client can reach LaunchDarkly. Flags not present in the override data are completely unaffected.

The override source is not a data source. It has no effect on the client's initialization status, data availability, or data source status. Without a configured source, or while the source supplies no overrides, the SDK behaves as it would without this feature.

At most one override source can be configured. A later call replaces an earlier one.

When the client is offline, the source is not built or started: no overrides are served, and a configuration error in the source is not reported. The SDK logs a warning instead.

Examples:

overrides = LaunchDarkly::Integrations::FileData.override_source(paths: ["/etc/launchdarkly/overrides.json"])
config = LaunchDarkly::Config.new(data_system_config: LaunchDarkly::DataSystem.default.overrides(overrides).build)

Parameters:

Returns:



116
117
118
119
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 116

def overrides(source)
  @overrides = source
  self
end

#synchronizers(synchronizers) ⇒ ConfigBuilder

Sets the synchronizers for the data system.

Synchronizers keep data up-to-date after initialization. Like initializers, they are tried in order. If the primary synchronizer fails, the next one takes over.

Parameters:

  • synchronizers (Array<#build(String, Config)>) —

    Array of builders that respond to build(sdk_key, config) and return a Synchronizer

Returns:



55
56
57
58
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 55

def synchronizers(synchronizers)
  @synchronizers = synchronizers
  self
end