Class: Sqreen::Deliveries::Batch
- Defined in:
- lib/sqreen/deliveries/batch.rb
Overview
Simple delivery method that batch event already seen in a batch
Instance Attribute Summary collapse
-
#current_batch ⇒ Object
Returns the value of attribute current_batch.
-
#first_seen ⇒ Object
Returns the value of attribute first_seen.
-
#max_batch ⇒ Object
Returns the value of attribute max_batch.
-
#max_staleness ⇒ Object
Returns the value of attribute max_staleness.
Attributes inherited from Simple
Instance Method Summary collapse
- #drain ⇒ Object
-
#initialize(session, max_batch, max_staleness, randomize_staleness = true) ⇒ Batch
constructor
A new instance of Batch.
- #post_event(event) ⇒ Object
- #tick ⇒ Object
Methods included from Log::Loggable
Constructor Details
#initialize(session, max_batch, max_staleness, randomize_staleness = true) ⇒ Batch
Returns a new instance of Batch.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sqreen/deliveries/batch.rb', line 26 def initialize(session, max_batch, max_staleness, randomize_staleness = true) super(session) self.max_batch = max_batch self.max_staleness = max_staleness @original_max_staleness = max_staleness self.current_batch = [] @first_seen = {} @randomize_staleness = randomize_staleness end |
Instance Attribute Details
#current_batch ⇒ Object
Returns the value of attribute current_batch.
24 25 26 |
# File 'lib/sqreen/deliveries/batch.rb', line 24 def current_batch @current_batch end |
#first_seen ⇒ Object
Returns the value of attribute first_seen.
24 25 26 |
# File 'lib/sqreen/deliveries/batch.rb', line 24 def first_seen @first_seen end |
#max_batch ⇒ Object
Returns the value of attribute max_batch.
23 24 25 |
# File 'lib/sqreen/deliveries/batch.rb', line 23 def max_batch @max_batch end |
#max_staleness ⇒ Object
Returns the value of attribute max_staleness.
23 24 25 |
# File 'lib/sqreen/deliveries/batch.rb', line 23 def max_staleness @max_staleness end |
Instance Method Details
#drain ⇒ Object
44 45 46 |
# File 'lib/sqreen/deliveries/batch.rb', line 44 def drain post_batch unless current_batch.empty? end |
#post_event(event) ⇒ Object
39 40 41 42 |
# File 'lib/sqreen/deliveries/batch.rb', line 39 def post_event(event) current_batch.push(event) post_batch if post_batch_needed?(event) end |
#tick ⇒ Object
48 49 50 |
# File 'lib/sqreen/deliveries/batch.rb', line 48 def tick post_batch if !current_batch.empty? && stale? end |