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
-
#build(sdk_key, config) ⇒ LaunchDarkly::Impl::DataSystem::PollingDataSource
Builds the polling data source with the configured parameters.
-
#initialize ⇒ PollingDataSourceBuilder
constructor
A new instance of PollingDataSourceBuilder.
-
#poll_interval(secs) ⇒ PollingDataSourceBuilder
Sets the polling interval in seconds.
-
#requester(requester) ⇒ PollingDataSourceBuilder
Sets a custom Requester for this polling data source.
Methods included from DataSourceBuilderCommon
#base_uri, #connect_timeout, #read_timeout, #socket_factory
Constructor Details
#initialize ⇒ PollingDataSourceBuilder
Returns a new instance of PollingDataSourceBuilder.
96 97 98 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 96 def initialize @requester = nil end |
Instance Method Details
#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.
144 145 146 147 148 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 144 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 |
#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.
110 111 112 113 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 110 def poll_interval(secs) @poll_interval = secs self end |
#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.
128 129 130 131 |
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 128 def requester(requester) @requester = requester self end |