Class: LaunchDarkly::DataSystem::PollingDataSourceBuilder
- Inherits:
-
Object
- Object
- LaunchDarkly::DataSystem::PollingDataSourceBuilder
- Includes:
- DataSourceBuilderCommon
- Defined in:
- lib/ldclient-rb/data_system/polling_data_source_builder.rb
Overview
Builder for a polling data source that communicates with LaunchDarkly's FDv2 polling endpoint.
This builder can be used with ConfigBuilder#initializers or ConfigBuilder#synchronizers to create custom data system configurations.
The polling data source periodically fetches data from LaunchDarkly. It supports conditional requests via ETags, so subsequent polls after the initial request only transfer data if changes have occurred.
Example
polling = LaunchDarkly::DataSystem.polling_ds_builder
.poll_interval(60)
.base_uri("https://custom-endpoint.example.com")
data_system = LaunchDarkly::DataSystem.custom
.synchronizers([polling])
Constant Summary collapse
- DEFAULT_BASE_URI =
Returns The default base URI for polling requests.
"https://sdk.launchdarkly.com"- DEFAULT_POLL_INTERVAL =
Returns The default polling interval in seconds.
30
Instance Method Summary collapse
-
#base_uri(uri) ⇒ self
included
from DataSourceBuilderCommon
Sets the base URI for HTTP requests.
-
#build(sdk_key, config) ⇒ LaunchDarkly::Impl::DataSystem::PollingDataSource
Builds the polling data source with the configured parameters.
-
#connect_timeout(timeout) ⇒ self
included
from DataSourceBuilderCommon
Sets the connect timeout for HTTP connections.
-
#initialize ⇒ PollingDataSourceBuilder
constructor
A new instance of PollingDataSourceBuilder.
-
#poll_interval(secs) ⇒ PollingDataSourceBuilder
Sets the polling interval in seconds.
-
#read_timeout(timeout) ⇒ self
included
from DataSourceBuilderCommon
Sets the read timeout for HTTP connections.
-
#requester(requester) ⇒ PollingDataSourceBuilder
Sets a custom Requester for this polling data source.
-
#socket_factory(factory) ⇒ self
included
from DataSourceBuilderCommon
Sets a custom socket factory for HTTP connections.
Constructor Details
#initialize ⇒ PollingDataSourceBuilder
Returns a new instance of PollingDataSourceBuilder.
98 99 100 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 98 def initialize @requester = nil end |
Instance Method Details
#base_uri(uri) ⇒ self Originally defined in module DataSourceBuilderCommon
Sets the base URI for HTTP requests.
Use this to point the SDK at a Relay Proxy instance or any other URI that implements the corresponding LaunchDarkly API.
#build(sdk_key, config) ⇒ LaunchDarkly::Impl::DataSystem::PollingDataSource
Builds the polling data source with the configured parameters.
This method is called internally by the SDK. You do not need to call it directly; instead, pass the builder to ConfigBuilder#initializers or ConfigBuilder#synchronizers.
146 147 148 149 150 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 146 def build(sdk_key, config) http_opts = build_http_config requester = @requester || LaunchDarkly::Impl::DataSystem::HTTPPollingRequester.new(sdk_key, http_opts, config) LaunchDarkly::Impl::DataSystem::PollingDataSource.new(@poll_interval || DEFAULT_POLL_INTERVAL, requester, config.logger) end |
#connect_timeout(timeout) ⇒ self Originally defined in module DataSourceBuilderCommon
Sets the connect timeout for HTTP connections.
#poll_interval(secs) ⇒ PollingDataSourceBuilder
Sets the polling interval in seconds.
This controls how frequently the SDK polls LaunchDarkly for updates. Lower values mean more frequent updates but higher network traffic. The default is DEFAULT_POLL_INTERVAL seconds.
112 113 114 115 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 112 def poll_interval(secs) @poll_interval = secs self end |
#read_timeout(timeout) ⇒ self Originally defined in module DataSourceBuilderCommon
Sets the read timeout for HTTP connections.
#requester(requester) ⇒ PollingDataSourceBuilder
Sets a custom Requester for this polling data source.
By default, the builder uses an HTTP requester that communicates with LaunchDarkly's FDv2 polling endpoint. Use this method to provide a custom requester implementation for testing or non-standard environments.
130 131 132 133 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 130 def requester(requester) @requester = requester self end |
#socket_factory(factory) ⇒ self Originally defined in module DataSourceBuilderCommon
Sets a custom socket factory for HTTP connections.