Class: LaunchDarkly::EventBuffer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/events.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(capacity, logger) ⇒ EventBuffer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of EventBuffer.



448
449
450
451
452
453
454
455
# File 'lib/ldclient-rb/events.rb', line 448

def initialize(capacity, logger)
  @capacity = capacity
  @logger = logger
  @capacity_exceeded = false
  @dropped_events = 0
  @events = []
  @summarizer = LaunchDarkly::Impl::EventSummarizer.new
end

Instance Method Details

#add_event(event) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/ldclient-rb/events.rb', line 457

def add_event(event)
  if @events.length < @capacity
    @events.push(event)
    @capacity_exceeded = false
  else
    @dropped_events += 1
    unless @capacity_exceeded
      @capacity_exceeded = true
      @logger.warn { "[LDClient] Exceeded event queue capacity. Increase capacity to avoid dropping events." }
    end
  end
end

#add_to_summary(event) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



470
471
472
# File 'lib/ldclient-rb/events.rb', line 470

def add_to_summary(event)
  @summarizer.summarize_event(event)
end

#clear ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



484
485
486
487
# File 'lib/ldclient-rb/events.rb', line 484

def clear
  @events = []
  @summarizer.clear
end

#get_and_clear_dropped_count ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



478
479
480
481
482
# File 'lib/ldclient-rb/events.rb', line 478

def get_and_clear_dropped_count
  ret = @dropped_events
  @dropped_events = 0
  ret
end

#get_payload ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



474
475
476
# File 'lib/ldclient-rb/events.rb', line 474

def get_payload
  FlushPayload.new(@events, @summarizer.snapshot)
end