Class: Deimos::BatchConsumer
- Inherits:
-
BaseConsumer
- Object
- BaseConsumer
- Deimos::BatchConsumer
- Includes:
- Phobos::BatchHandler
- Defined in:
- lib/deimos/batch_consumer.rb
Overview
Class to consume batches of messages in a topic Note: According to the docs, instances of your handler will be created for every incoming batch of messages. This class should be lightweight.
Instance Method Summary collapse
-
#around_consume_batch(batch, metadata) ⇒ Object
:nodoc:.
-
#consume_batch(_payloads, _metadata) ⇒ Object
Consume a batch of incoming messages.
Methods inherited from BaseConsumer
#decode_key, decoder, key_decoder
Instance Method Details
#around_consume_batch(batch, metadata) ⇒ Object
:nodoc:
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/deimos/batch_consumer.rb', line 14 def around_consume_batch(batch, ) payloads = [] benchmark = Benchmark.measure do if self.class.config[:key_configured] [:keys] = batch.map do || decode_key(.key) end end payloads = batch.map do || .payload ? self.class.decoder.decode(.payload) : nil end _received_batch(payloads, ) _with_error_span(payloads, ) do yield payloads, end end _handle_success(benchmark.real, payloads, ) end |
#consume_batch(_payloads, _metadata) ⇒ Object
Consume a batch of incoming messages.
37 38 39 |
# File 'lib/deimos/batch_consumer.rb', line 37 def consume_batch(_payloads, ) raise NotImplementedError end |