33require "ldclient-rb/impl/event_sender"
44require "ldclient-rb/impl/event_summarizer"
55require "ldclient-rb/impl/event_types"
6+ require "ldclient-rb/impl/non_blocking_thread_pool"
7+ require "ldclient-rb/impl/simple_lru_cache"
68require "ldclient-rb/impl/util"
79
810require "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'
0 commit comments