Class: Rabbitek::Batcher
- Inherits:
-
Object
- Object
- Rabbitek::Batcher
- Defined in:
- lib/rabbitek/server/batcher.rb
Overview
A service to group messages from queue by batches.
Instance Method Summary collapse
-
#initialize(consumer) ⇒ Batcher
constructor
A new instance of Batcher.
- #perform(message) ⇒ Object
Constructor Details
#initialize(consumer) ⇒ Batcher
Returns a new instance of Batcher.
7 8 9 10 11 |
# File 'lib/rabbitek/server/batcher.rb', line 7 def initialize(consumer) @consumer = consumer @batch_size = consumer.opts[:batch][:of] @batch = [] end |
Instance Method Details
#perform(message) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rabbitek/server/batcher.rb', line 13 def perform() collect_batch() yield(@batch) rescue StandardError raise end |