Module: LaunchDarkly::DataSystem

Defined in:
lib/ldclient-rb/data_system.rb,
lib/ldclient-rb/data_system/config_builder.rb,
lib/ldclient-rb/data_system/data_source_builder_common.rb,
lib/ldclient-rb/data_system/polling_data_source_builder.rb,
lib/ldclient-rb/data_system/streaming_data_source_builder.rb

Overview

Configuration for LaunchDarkly's data acquisition strategy.

This module provides factory methods for creating data system configurations, as well as builder classes for constructing individual data sources (polling and streaming).

== Quick Start

For most users, the predefined strategies are sufficient:

# Use the default strategy (recommended) config = LaunchDarkly::Config.new( data_system: LaunchDarkly::DataSystem.default )

# Use streaming only config = LaunchDarkly::Config.new( data_system: LaunchDarkly::DataSystem.streaming )

# Use polling only config = LaunchDarkly::Config.new( data_system: LaunchDarkly::DataSystem.polling )

== Custom Configurations

For advanced use cases, you can build custom configurations using the data source builders:

polling = LaunchDarkly::DataSystem.polling_ds_builder .poll_interval(60) .base_uri("https://custom-polling.example.com")

streaming = LaunchDarkly::DataSystem.streaming_ds_builder .initial_reconnect_delay(2) .base_uri("https://custom-streaming.example.com")

data_system = LaunchDarkly::DataSystem.custom .initializers([polling]) .synchronizers([streaming, polling])

config = LaunchDarkly::Config.new(data_system: data_system)

Defined Under Namespace

Modules: DataSourceBuilderCommon, Requester Classes: ConfigBuilder, FDv1PollingDataSourceBuilder, PollingDataSourceBuilder, StreamingDataSourceBuilder

Class Method Summary collapse

Class Method Details

.customConfigBuilder

Custom returns a builder suitable for creating a custom data acquisition strategy. You may configure how the SDK uses a Persistent Store, how the SDK obtains an initial set of data, and how the SDK keeps data up-to-date.

Returns:



162
163
164
# File 'lib/ldclient-rb/data_system.rb', line 162

def self.custom
  ConfigBuilder.new
end

.daemon(store) ⇒ ConfigBuilder

Daemon configures the SDK to read from a persistent store integration that is populated by Relay Proxy or other SDKs. The SDK will not connect to LaunchDarkly. In this mode, the SDK never writes to the data store.

Parameters:

  • store (Object)

    The persistent store

Returns:



174
175
176
# File 'lib/ldclient-rb/data_system.rb', line 174

def self.daemon(store)
  custom.data_store(store, LaunchDarkly::Interfaces::DataSystem::DataStoreMode::READ_ONLY)
end

.defaultConfigBuilder

Default is LaunchDarkly's recommended flag data acquisition strategy.

Currently, it operates a two-phase method for obtaining data: first, it requests data from LaunchDarkly's global CDN. Then, it initiates a streaming connection to LaunchDarkly's Flag Delivery services to receive real-time updates.

If the streaming connection is interrupted for an extended period of time, the SDK will automatically fall back to polling the global CDN for updates.

Returns:



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/ldclient-rb/data_system.rb', line 105

def self.default
  polling_builder = polling_ds_builder
  streaming_builder = streaming_ds_builder
  fallback = fdv1_fallback_ds_builder

  builder = ConfigBuilder.new
  builder.initializers([polling_builder])
  builder.synchronizers([streaming_builder, polling_builder])
  builder.fdv1_compatible_synchronizer(fallback)

  builder
end

.fdv1_fallback_ds_builderFDv1PollingDataSourceBuilder

Returns a builder for creating an FDv1 fallback polling data source. This is a building block that can be used with LaunchDarkly::DataSystem::ConfigBuilder#fdv1_compatible_synchronizer to provide FDv1 compatibility in custom data system configurations.



76
77
78
# File 'lib/ldclient-rb/data_system.rb', line 76

def self.fdv1_fallback_ds_builder
  FDv1PollingDataSourceBuilder.new
end

.persistent_store(store) ⇒ ConfigBuilder

PersistentStore is similar to default, with the addition of a persistent store integration. Before data has arrived from LaunchDarkly, the SDK is able to evaluate flags using data from the persistent store. Once fresh data is available, the SDK will no longer read from the persistent store, although it will keep it up-to-date.

Parameters:

  • store (Object)

    The persistent store

Returns:



188
189
190
# File 'lib/ldclient-rb/data_system.rb', line 188

def self.persistent_store(store)
  default.data_store(store, LaunchDarkly::Interfaces::DataSystem::DataStoreMode::READ_WRITE)
end

.pollingConfigBuilder

Polling configures the SDK to regularly poll an endpoint for flag/segment data in the background. This is less efficient than streaming, but may be necessary in some network environments.

Returns:



143
144
145
146
147
148
149
150
151
152
# File 'lib/ldclient-rb/data_system.rb', line 143

def self.polling
  polling_builder = polling_ds_builder
  fallback = fdv1_fallback_ds_builder

  builder = ConfigBuilder.new
  builder.synchronizers([polling_builder])
  builder.fdv1_compatible_synchronizer(fallback)

  builder
end

.polling_ds_builderPollingDataSourceBuilder

Returns a builder for creating a polling data source. This is a building block that can be used with LaunchDarkly::DataSystem::ConfigBuilder#initializers or LaunchDarkly::DataSystem::ConfigBuilder#synchronizers to create custom data system configurations.



65
66
67
# File 'lib/ldclient-rb/data_system.rb', line 65

def self.polling_ds_builder
  PollingDataSourceBuilder.new
end

.streamingConfigBuilder

Streaming configures the SDK to efficiently stream flag/segment data in the background, allowing evaluations to operate on the latest data with no additional latency.

Returns:



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

def self.streaming
  streaming_builder = streaming_ds_builder
  fallback = fdv1_fallback_ds_builder

  builder = ConfigBuilder.new
  builder.synchronizers([streaming_builder])
  builder.fdv1_compatible_synchronizer(fallback)

  builder
end

.streaming_ds_builderStreamingDataSourceBuilder

Returns a builder for creating a streaming data source. This is a building block that can be used with LaunchDarkly::DataSystem::ConfigBuilder#synchronizers to create custom data system configurations.



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

def self.streaming_ds_builder
  StreamingDataSourceBuilder.new
end