Class: LaunchDarkly::DataSystem::FDv1PollingDataSourceBuilder

Inherits:
Object
  • Object
show all
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 FDv1 (Flag Delivery v1) polling endpoint.

This builder is typically used with ConfigBuilder#fdv1_compatible_synchronizer to provide a fallback when the server signals that the environment should revert to the FDv1 protocol.

Most users will not need to interact with this builder directly, as the predefined strategies (default, streaming, polling) already configure an appropriate FDv1 fallback.

Constant Summary collapse

DEFAULT_BASE_URI =

Returns The default base URI for FDv1 polling requests.

Returns:

  • (String)

    The default base URI for FDv1 polling requests

"https://sdk.launchdarkly.com"
DEFAULT_POLL_INTERVAL =

Returns The default polling interval in seconds.

Returns:

  • (Float)

    The default polling interval in seconds

30

Instance Method Summary collapse

Constructor Details

#initializeFDv1PollingDataSourceBuilder

Returns a new instance of FDv1PollingDataSourceBuilder.



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

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.

Parameters:

Returns:

  • (self)

    the builder, for chaining

#build(sdk_key, config) ⇒ LaunchDarkly::Impl::DataSystem::PollingDataSource

Builds the FDv1 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#fdv1_compatible_synchronizer.

Parameters:

Returns:

  • (LaunchDarkly::Impl::DataSystem::PollingDataSource)


220
221
222
223
224
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 220

def build(sdk_key, config)
  http_opts = build_http_config
  requester = @requester || LaunchDarkly::Impl::DataSystem::HTTPFDv1PollingRequester.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.

Parameters:

  • timeout (Float)

    Timeout in seconds

Returns:

  • (self)

    the builder, for chaining

#poll_interval(secs) ⇒ FDv1PollingDataSourceBuilder

Sets the polling interval in seconds.

This controls how frequently the SDK polls LaunchDarkly for updates. The default is DEFAULT_POLL_INTERVAL seconds.

Parameters:

  • secs (Float)

    Polling interval in seconds

Returns:



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

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.

Parameters:

  • timeout (Float)

    Timeout in seconds

Returns:

  • (self)

    the builder, for chaining

#requester(requester) ⇒ FDv1PollingDataSourceBuilder

Sets a custom Requester for this polling data source.

By default, the builder uses an HTTP requester that communicates with LaunchDarkly's FDv1 polling endpoint. Use this method to provide a custom requester implementation.

Parameters:

Returns:

See Also:



205
206
207
208
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 205

def requester(requester)
  @requester = requester
  self
end

#socket_factory(factory) ⇒ self Originally defined in module DataSourceBuilderCommon

Sets a custom socket factory for HTTP connections.

Parameters:

  • factory (#open)

    A socket factory that responds to +open+

Returns:

  • (self)

    the builder, for chaining