Class: LaunchDarkly::EventDispatcher
- Inherits:
-
Object
- Object
- LaunchDarkly::EventDispatcher
- Defined in:
- lib/ldclient-rb/events.rb
Instance Method Summary collapse
-
#initialize(inbox, sdk_key, config, diagnostic_accumulator, event_sender) ⇒ EventDispatcher
constructor
A new instance of EventDispatcher.
Constructor Details
#initialize(inbox, sdk_key, config, diagnostic_accumulator, event_sender) ⇒ EventDispatcher
Returns a new instance of EventDispatcher.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/ldclient-rb/events.rb', line 231 def initialize(inbox, sdk_key, config, diagnostic_accumulator, event_sender) @sdk_key = sdk_key @config = config @diagnostic_accumulator = config.diagnostic_opt_out? ? nil : diagnostic_accumulator @event_sender = event_sender @sampler = LaunchDarkly::Impl::Sampler.new(Random.new) @context_keys = SimpleLRUCacheSet.new(config.context_keys_capacity) @formatter = EventOutputFormatter.new(config) @disabled = Concurrent::AtomicBoolean.new(false) @last_known_past_time = Concurrent::AtomicReference.new(0) @deduplicated_contexts = 0 @events_in_last_batch = 0 outbox = EventBuffer.new(config.capacity, config.logger) flush_workers = NonBlockingThreadPool.new(MAX_FLUSH_WORKERS) if !@diagnostic_accumulator.nil? diagnostic_event_workers = NonBlockingThreadPool.new(1) init_event = @diagnostic_accumulator.create_init_event(config) send_diagnostic_event(init_event, diagnostic_event_workers) else diagnostic_event_workers = nil end Thread.new { main_loop(inbox, outbox, flush_workers, diagnostic_event_workers) } end |