Class: LaunchDarkly::EventBuffer
- Inherits:
-
Object
- Object
- LaunchDarkly::EventBuffer
- Defined in:
- lib/ldclient-rb/events.rb
Instance Method Summary collapse
- #add_event(event) ⇒ Object
- #add_to_summary(event) ⇒ Object
- #clear ⇒ Object
- #get_and_clear_dropped_count ⇒ Object
- #get_payload ⇒ Object
-
#initialize(capacity, logger) ⇒ EventBuffer
constructor
A new instance of EventBuffer.
Constructor Details
#initialize(capacity, logger) ⇒ EventBuffer
Returns a new instance of EventBuffer.
422 423 424 425 426 427 428 429 |
# File 'lib/ldclient-rb/events.rb', line 422 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
431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/ldclient-rb/events.rb', line 431 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
444 445 446 |
# File 'lib/ldclient-rb/events.rb', line 444 def add_to_summary(event) @summarizer.summarize_event(event) end |
#clear ⇒ Object
458 459 460 461 |
# File 'lib/ldclient-rb/events.rb', line 458 def clear @events = [] @summarizer.clear end |
#get_and_clear_dropped_count ⇒ Object
452 453 454 455 456 |
# File 'lib/ldclient-rb/events.rb', line 452 def get_and_clear_dropped_count ret = @dropped_events @dropped_events = 0 ret end |
#get_payload ⇒ Object
448 449 450 |
# File 'lib/ldclient-rb/events.rb', line 448 def get_payload FlushPayload.new(@events, @summarizer.snapshot) end |