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

#initializeConfigBuilder

Returns a new instance of ConfigBuilder.



20
21
22
23
24
25
26
# 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
end

Instance Method Details

#buildDataSystemConfig

Builds the data system configuration.

Returns:



93
94
95
96
97
98
99
100
101
# File 'lib/ldclient-rb/data_system/config_builder.rb', line 93

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

#data_store(data_store, store_mode) ⇒ ConfigBuilder

Sets the data store configuration for the data system.

Parameters:

Returns:



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

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:



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

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:



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

def initializers(initializers)
  @initializers = initializers
  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:



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

def synchronizers(synchronizers)
  @synchronizers = synchronizers
  self
end