Skip to content

Commit 59ae3c0

Browse files
committed
Update comments, make forwardable
1 parent ff845d5 commit 59ae3c0

File tree

2 files changed

+31
-51
lines changed

2 files changed

+31
-51
lines changed

lib/ldclient-rb/events.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ def record_custom_event(
6262
def record_migration_op_event(event)
6363
end
6464

65+
#
66+
# Tells the event processor that all pending analytics events should be delivered as soon as possible.
67+
#
68+
# When the LaunchDarkly client generates analytics events (from {LaunchDarkly::LDClient#variation},
69+
# {LaunchDarkly::LDClient#variation_detail}, {LaunchDarkly::LDClient#identify}, or
70+
# {LaunchDarkly::LDClient#track}), they are queued on a worker thread. The event thread normally
71+
# sends all queued events to LaunchDarkly at regular intervals, controlled by the
72+
# {LaunchDarkly::Config#flush_interval} option. Calling `flush` triggers a send without waiting
73+
# for the next interval.
74+
#
75+
# Flushing is asynchronous, so this method will return before it is complete. However, if you
76+
# call {LaunchDarkly::LDClient#close}, events are guaranteed to be sent before that method returns.
77+
#
6578
def flush
6679
end
6780

lib/ldclient-rb/ldclient.rb

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ class LDClient
3232

3333
def_delegators :@config, :logger
3434

35+
# @!method flush
36+
# Delegates to {LaunchDarkly::EventProcessorMethods#flush}.
37+
def_delegator :@event_processor, :flush
38+
39+
# @!method data_store_status_provider
40+
# Delegates to the data system {LaunchDarkly::Impl::DataSystem#data_store_status_provider}.
41+
# @return [LaunchDarkly::Interfaces::DataStore::StatusProvider]
42+
# @!method data_source_status_provider
43+
# Delegates to the data system {LaunchDarkly::Impl::DataSystem#data_source_status_provider}.
44+
# @return [LaunchDarkly::Interfaces::DataSource::StatusProvider]
45+
def_delegators :@data_system, :data_store_status_provider, :data_source_status_provider
46+
3547
#
3648
# Creates a new client instance that connects to LaunchDarkly. A custom
3749
# configuration parameter can also supplied to specify advanced options,
@@ -50,11 +62,13 @@ class LDClient
5062
#
5163
def initialize(sdk_key, config = Config.default, wait_for_sec = 5)
5264
# Note that sdk_key is normally a required parameter, and a nil value would cause the SDK to
53-
# fail in most configurations. However, there are some configurations where it would be OK
54-
# (offline = true, *or* we are using LDD mode or the file data source and events are disabled
55-
# so we're not connecting to any LD services).
65+
# fail in most configurations. However, there are some configurations where it would be OK to
66+
# not provide a SDK key.
67+
# * Offline mode
68+
# * Using LDD mode with events disabled
69+
# * Using a custom data source (like FileData) with events disabled
5670
if !config.offline? && sdk_key.nil?
57-
# SDK key can be nil only if using LDD or custom data source with events disabled
71+
# If the data source is nil we create a default data source which requires the SDK key.
5872
if config.send_events || (!config.use_ldd? && config.data_source.nil?)
5973
raise ArgumentError, "sdk_key must not be nil"
6074
end
@@ -206,22 +220,6 @@ def add_hook(hook)
206220
@hooks.push(hook)
207221
end
208222

209-
#
210-
# Tells the client that all pending analytics events should be delivered as soon as possible.
211-
#
212-
# When the LaunchDarkly client generates analytics events (from {#variation}, {#variation_detail},
213-
# {#identify}, or {#track}), they are queued on a worker thread. The event thread normally
214-
# sends all queued events to LaunchDarkly at regular intervals, controlled by the
215-
# {Config#flush_interval} option. Calling `flush` triggers a send without waiting for the
216-
# next interval.
217-
#
218-
# Flushing is asynchronous, so this method will return before it is complete. However, if you
219-
# call {#close}, events are guaranteed to be sent before that method returns.
220-
#
221-
def flush
222-
@event_processor.flush
223-
end
224-
225223
#
226224
# Creates a hash string that can be used by the JavaScript SDK to identify a context.
227225
# For more information, see [Secure mode](https://docs.launchdarkly.com/sdk/features/secure-mode#ruby).
@@ -639,37 +637,6 @@ def close
639637
#
640638
attr_reader :big_segment_store_status_provider
641639

642-
#
643-
# Returns an interface for tracking the status of a persistent data store.
644-
#
645-
# The {LaunchDarkly::Interfaces::DataStore::StatusProvider} has methods for
646-
# checking whether the data store is (as far as the SDK knows) currently
647-
# operational, tracking changes in this status, and getting cache
648-
# statistics. These are only relevant for a persistent data store; if you
649-
# are using an in-memory data store, then this method will return a stub
650-
# object that provides no information.
651-
#
652-
# @return [LaunchDarkly::Interfaces::DataStore::StatusProvider]
653-
#
654-
def data_store_status_provider
655-
@data_system.data_store_status_provider
656-
end
657-
658-
#
659-
# Returns an interface for tracking the status of the data source.
660-
#
661-
# The data source is the mechanism that the SDK uses to get feature flag
662-
# configurations, such as a streaming connection (the default) or poll
663-
# requests. The {LaunchDarkly::Interfaces::DataSource::StatusProvider} has
664-
# methods for checking whether the data source is (as far as the SDK knows)
665-
# currently operational and tracking changes in this status.
666-
#
667-
# @return [LaunchDarkly::Interfaces::DataSource::StatusProvider]
668-
#
669-
def data_source_status_provider
670-
@data_system.data_source_status_provider
671-
end
672-
673640
#
674641
# Returns an interface for tracking changes in feature flag configurations.
675642
#

0 commit comments

Comments
 (0)