Skip to content

Commit 2532600

Browse files
authored
chore: Update yard tags, and locations for private implementations (#340)
1 parent aa56ee5 commit 2532600

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1157
-1109
lines changed

lib/ldclient-rb.rb

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,14 @@
55
module LaunchDarkly
66
end
77

8-
require "ldclient-rb/version"
9-
require "ldclient-rb/interfaces"
10-
require "ldclient-rb/util"
11-
require "ldclient-rb/flags_state"
12-
require "ldclient-rb/migrations"
13-
require "ldclient-rb/ldclient"
14-
require "ldclient-rb/cache_store"
15-
require "ldclient-rb/expiring_cache"
16-
require "ldclient-rb/memoized_value"
17-
require "ldclient-rb/in_memory_store"
8+
# Public APIs - these define the main interfaces users interact with
189
require "ldclient-rb/config"
1910
require "ldclient-rb/context"
20-
require "ldclient-rb/reference"
21-
require "ldclient-rb/stream"
22-
require "ldclient-rb/polling"
23-
require "ldclient-rb/simple_lru_cache"
24-
require "ldclient-rb/non_blocking_thread_pool"
25-
require "ldclient-rb/events"
26-
require "ldclient-rb/requestor"
11+
require "ldclient-rb/flags_state"
2712
require "ldclient-rb/integrations"
13+
require "ldclient-rb/interfaces"
14+
require "ldclient-rb/ldclient"
15+
require "ldclient-rb/migrations"
16+
require "ldclient-rb/reference"
17+
require "ldclient-rb/util"
18+
require "ldclient-rb/version"

lib/ldclient-rb/cache_store.rb

Lines changed: 0 additions & 45 deletions
This file was deleted.

lib/ldclient-rb/config.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "logger"
2+
require "ldclient-rb/impl/cache_store"
23

34
module LaunchDarkly
45
#
@@ -96,7 +97,7 @@ def initialize(opts = {})
9697
# Custom data source implementations should integrate with this sink if
9798
# they want to provide support for data source status listeners.
9899
#
99-
# @private
100+
# @api private
100101
#
101102
attr_accessor :data_source_update_sink
102103

@@ -108,7 +109,7 @@ def initialize(opts = {})
108109
# property is not supported; it is temporarily being exposed to maintain
109110
# backwards compatibility while the SDK structure is updated.
110111
#
111-
# @private
112+
# @api private
112113
#
113114
attr_accessor :instance_id
114115

@@ -477,7 +478,7 @@ def self.default_events_uri
477478
# @return [Object] the Rails cache if in Rails, or a simple in-memory implementation otherwise
478479
#
479480
def self.default_cache_store
480-
defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : ThreadSafeMemoryStore.new
481+
defined?(Rails) && Rails.respond_to?(:cache) ? Rails.cache : Impl::ThreadSafeMemoryStore.new
481482
end
482483

483484
#

lib/ldclient-rb/context.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class LDContext
4848
attr_reader :error
4949

5050
#
51-
# @private
51+
# @api private
5252
# @param key [String, nil]
5353
# @param fully_qualified_key [String, nil]
5454
# @param kind [String, nil]

lib/ldclient-rb/events.rb

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
require "ldclient-rb/impl/event_sender"
44
require "ldclient-rb/impl/event_summarizer"
55
require "ldclient-rb/impl/event_types"
6+
require "ldclient-rb/impl/non_blocking_thread_pool"
7+
require "ldclient-rb/impl/simple_lru_cache"
68
require "ldclient-rb/impl/util"
79

810
require "concurrent"
@@ -70,24 +72,24 @@ def stop
7072
MAX_FLUSH_WORKERS = 5
7173
private_constant :MAX_FLUSH_WORKERS
7274

73-
# @private
75+
# @api private
7476
class NullEventProcessor
7577
include EventProcessorMethods
7678
end
7779

78-
# @private
80+
# @api private
7981
class FlushMessage
8082
end
8183

82-
# @private
84+
# @api private
8385
class FlushContextsMessage
8486
end
8587

86-
# @private
88+
# @api private
8789
class DiagnosticEventMessage
8890
end
8991

90-
# @private
92+
# @api private
9193
class SynchronousMessage
9294
def initialize
9395
@reply = Concurrent::Semaphore.new(0)
@@ -102,15 +104,15 @@ def wait_for_completion
102104
end
103105
end
104106

105-
# @private
107+
# @api private
106108
class TestSyncMessage < SynchronousMessage
107109
end
108110

109-
# @private
111+
# @api private
110112
class StopMessage < SynchronousMessage
111113
end
112114

113-
# @private
115+
# @api private
114116
class EventProcessor
115117
include EventProcessorMethods
116118

@@ -141,7 +143,7 @@ def initialize(sdk_key, config, client = nil, diagnostic_accumulator = nil, test
141143
@inbox_full = Concurrent::AtomicBoolean.new(false)
142144

143145
event_sender = (test_properties || {})[:event_sender] ||
144-
Impl::EventSender.new(sdk_key, config, client || Util.new_http_client(config.events_uri, config))
146+
Impl::EventSender.new(sdk_key, config, client || Impl::Util.new_http_client(config.events_uri, config))
145147

146148
@timestamp_fn = (test_properties || {})[:timestamp_fn] || proc { Impl::Util.current_time_millis }
147149
@omit_anonymous_contexts = config.omit_anonymous_contexts
@@ -226,7 +228,7 @@ def wait_until_inactive
226228
end
227229
end
228230

229-
# @private
231+
# @api private
230232
class EventDispatcher
231233
def initialize(inbox, sdk_key, config, diagnostic_accumulator, event_sender)
232234
@sdk_key = sdk_key
@@ -235,18 +237,18 @@ def initialize(inbox, sdk_key, config, diagnostic_accumulator, event_sender)
235237
@event_sender = event_sender
236238
@sampler = LaunchDarkly::Impl::Sampler.new(Random.new)
237239

238-
@context_keys = SimpleLRUCacheSet.new(config.context_keys_capacity)
240+
@context_keys = Impl::SimpleLRUCacheSet.new(config.context_keys_capacity)
239241
@formatter = EventOutputFormatter.new(config)
240242
@disabled = Concurrent::AtomicBoolean.new(false)
241243
@last_known_past_time = Concurrent::AtomicReference.new(0)
242244
@deduplicated_contexts = 0
243245
@events_in_last_batch = 0
244246

245247
outbox = EventBuffer.new(config.capacity, config.logger)
246-
flush_workers = NonBlockingThreadPool.new(MAX_FLUSH_WORKERS, 'LD/EventDispatcher/FlushWorkers')
248+
flush_workers = Impl::NonBlockingThreadPool.new(MAX_FLUSH_WORKERS, 'LD/EventDispatcher/FlushWorkers')
247249

248250
if !@diagnostic_accumulator.nil?
249-
diagnostic_event_workers = NonBlockingThreadPool.new(1, 'LD/EventDispatcher/DiagnosticEventWorkers')
251+
diagnostic_event_workers = Impl::NonBlockingThreadPool.new(1, 'LD/EventDispatcher/DiagnosticEventWorkers')
250252
init_event = @diagnostic_accumulator.create_init_event(config)
251253
send_diagnostic_event(init_event, diagnostic_event_workers)
252254
else
@@ -281,7 +283,7 @@ def main_loop(inbox, outbox, flush_workers, diagnostic_event_workers)
281283
dispatch_event(message, outbox)
282284
end
283285
rescue => e
284-
Util.log_exception(@config.logger, "Unexpected error in event processor", e)
286+
Impl::Util.log_exception(@config.logger, "Unexpected error in event processor", e)
285287
end
286288
end
287289
end
@@ -383,7 +385,7 @@ def trigger_flush(outbox, flush_workers)
383385
@last_known_past_time.value = (result.time_from_server.to_f * 1000).to_i
384386
end
385387
rescue => e
386-
Util.log_exception(@config.logger, "Unexpected error in event processor", e)
388+
Impl::Util.log_exception(@config.logger, "Unexpected error in event processor", e)
387389
end
388390
end
389391
outbox.clear if success # Reset our internal state, these events now belong to the flush worker
@@ -408,16 +410,16 @@ def send_diagnostic_event(event, diagnostic_event_workers)
408410
begin
409411
@event_sender.send_event_data(event.to_json, "diagnostic event", true)
410412
rescue => e
411-
Util.log_exception(@config.logger, "Unexpected error in event processor", e)
413+
Impl::Util.log_exception(@config.logger, "Unexpected error in event processor", e)
412414
end
413415
end
414416
end
415417
end
416418

417-
# @private
419+
# @api private
418420
FlushPayload = Struct.new(:events, :summary)
419421

420-
# @private
422+
# @api private
421423
class EventBuffer
422424
def initialize(capacity, logger)
423425
@capacity = capacity
@@ -461,7 +463,7 @@ def clear
461463
end
462464
end
463465

464-
# @private
466+
# @api private
465467
class EventOutputFormatter
466468
FEATURE_KIND = 'feature'
467469
IDENTIFY_KIND = 'identify'

lib/ldclient-rb/expiring_cache.rb

Lines changed: 0 additions & 77 deletions
This file was deleted.

lib/ldclient-rb/flags_state.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(valid)
1515
end
1616

1717
# Used internally to build the state map.
18-
# @private
18+
# @api private
1919
def add_flag(flag_state, with_reasons, details_only_if_tracked)
2020
key = flag_state[:key]
2121
@flag_values[key] = flag_state[:value]

lib/ldclient-rb/impl.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ module LaunchDarkly
55
# and subject to change.
66
#
77
# @since 5.5.0
8-
# @private
9-
#
8+
# @api private
109
module Impl
1110
# code is in ldclient-rb/impl/
1211
end

lib/ldclient-rb/impl/big_segments.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require "ldclient-rb/config"
2-
require "ldclient-rb/expiring_cache"
2+
require "ldclient-rb/impl/expiring_cache"
33
require "ldclient-rb/impl/repeating_task"
4+
require "ldclient-rb/impl/util"
45
require "ldclient-rb/interfaces"
5-
require "ldclient-rb/util"
66

77
require "digest"
88

@@ -45,7 +45,7 @@ def get_context_membership(context_key)
4545
membership = EMPTY_MEMBERSHIP if membership.nil?
4646
@cache[context_key] = membership
4747
rescue => e
48-
LaunchDarkly::Util.log_exception(@logger, "Big Segment store membership query returned error", e)
48+
Impl::Util.log_exception(@logger, "Big Segment store membership query returned error", e)
4949
return BigSegmentMembershipResult.new(nil, BigSegmentsStatus::STORE_ERROR)
5050
end
5151
end
@@ -67,7 +67,7 @@ def poll_store_and_update_status
6767
metadata = @store.get_metadata
6868
new_status = Interfaces::BigSegmentStoreStatus.new(true, !metadata || stale?(metadata.last_up_to_date))
6969
rescue => e
70-
LaunchDarkly::Util.log_exception(@logger, "Big Segment store status query returned error", e)
70+
Impl::Util.log_exception(@logger, "Big Segment store status query returned error", e)
7171
end
7272
end
7373
@last_status = new_status

0 commit comments

Comments
 (0)