class LaunchDarkly::EventBuffer

@private

Public Class Methods

new(capacity, logger) click to toggle source
# File lib/ldclient-rb/events.rb, line 362
def initialize(capacity, logger)
  @capacity = capacity
  @logger = logger
  @capacity_exceeded = false
  @dropped_events = 0
  @events = []
  @summarizer = EventSummarizer.new
end

Public Instance Methods

add_event(event) click to toggle source
# File lib/ldclient-rb/events.rb, line 371
def add_event(event)
  if @events.length < @capacity
    @logger.debug { "[LDClient] Enqueueing event: #{event.to_json}" }
    @events.push(event)
    @capacity_exceeded = false
  else
    @dropped_events += 1
    if !@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) click to toggle source
# File lib/ldclient-rb/events.rb, line 385
def add_to_summary(event)
  @summarizer.summarize_event(event)
end
clear() click to toggle source
# File lib/ldclient-rb/events.rb, line 399
def clear
  @events = []
  @summarizer.clear
end
get_and_clear_dropped_count() click to toggle source
# File lib/ldclient-rb/events.rb, line 393
def get_and_clear_dropped_count
  ret = @dropped_events
  @dropped_events = 0
  ret
end
get_payload() click to toggle source
# File lib/ldclient-rb/events.rb, line 389
def get_payload
  return FlushPayload.new(@events, @summarizer.snapshot)
end