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.



437
438
439
440
441
442
443
444
# File 'lib/ldclient-rb/events.rb', line 437

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.



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

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.



459
460
461
# File 'lib/ldclient-rb/events.rb', line 459

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

#clearObject

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.



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

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

#get_and_clear_dropped_countObject

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.



467
468
469
470
471
# File 'lib/ldclient-rb/events.rb', line 467

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

#get_payloadObject

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.



463
464
465
# File 'lib/ldclient-rb/events.rb', line 463

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