Module: LaunchDarkly::DataSystem::Requester

Defined in:
lib/ldclient-rb/data_system/polling_data_source_builder.rb

Overview

Interface for custom polling requesters.

A Requester is responsible for fetching data from a data source. The SDK ships with built-in HTTP requesters for both FDv2 and FDv1 polling endpoints, but you can implement this interface to provide custom data fetching logic (e.g., reading from a file, a database, or a custom API).

== Implementing a Custom Requester

To create a custom requester, include this module and implement the #fetch method:

class MyCustomRequester include LaunchDarkly::DataSystem::Requester

def fetch(selector)
  # Fetch data and return a Result containing [ChangeSet, headers]
  # ...
  LaunchDarkly::Result.success([change_set, {}])
end

def stop
  # Clean up resources
end

end

polling = LaunchDarkly::DataSystem.polling_ds_builder .requester(MyCustomRequester.new)

Instance Method Summary collapse

Instance Method Details

#fetch(selector) ⇒ LaunchDarkly::Result

Fetches data for the given selector.

Parameters:

Returns:

  • (LaunchDarkly::Result)

    A Result containing a tuple of [ChangeSet, headers] on success, or an error message on failure.

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 49

def fetch(selector)
  raise NotImplementedError
end

#stopObject

Releases any resources held by this requester (e.g., persistent HTTP connections). Called when the requester is no longer needed.

Implementations should handle being called multiple times gracefully. The default implementation is a no-op.



60
61
62
# File 'lib/ldclient-rb/data_system/polling_data_source_builder.rb', line 60

def stop
  # Optional - implementations may override if they need cleanup
end