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
-
.custom ⇒ ConfigBuilder
Custom returns a builder suitable for creating a custom data acquisition strategy.
-
.daemon(store) ⇒ ConfigBuilder
Daemon configures the SDK to read from a persistent store integration that is populated by Relay Proxy or other SDKs.
-
.default ⇒ ConfigBuilder
Default is LaunchDarkly's recommended flag data acquisition strategy.
-
.fdv1_fallback_ds_builder ⇒ FDv1PollingDataSourceBuilder
Returns a builder for creating an FDv1 fallback polling data source.
-
.persistent_store(store) ⇒ ConfigBuilder
PersistentStore is similar to default, with the addition of a persistent store integration.
-
.polling ⇒ ConfigBuilder
Polling configures the SDK to regularly poll an endpoint for flag/segment data in the background.
-
.polling_ds_builder ⇒ PollingDataSourceBuilder
Returns a builder for creating a polling data source.
-
.streaming ⇒ ConfigBuilder
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.
-
.streaming_ds_builder ⇒ StreamingDataSourceBuilder
Returns a builder for creating a streaming data source.
Class Method Details
.custom ⇒ ConfigBuilder
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.
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.
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 |
.default ⇒ ConfigBuilder
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.
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_builder ⇒ FDv1PollingDataSourceBuilder
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.
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 |
.polling ⇒ ConfigBuilder
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.
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_builder ⇒ PollingDataSourceBuilder
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 |
.streaming ⇒ ConfigBuilder
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.
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_builder ⇒ StreamingDataSourceBuilder
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 |