Class: Rimless::BaseConsumer
- Inherits:
-
Karafka::BaseConsumer
- Object
- Karafka::BaseConsumer
- Rimless::BaseConsumer
- Defined in:
- lib/rimless/base_consumer.rb
Overview
The base consumer where all Apache Kafka messages will be processed. It comes with some simple conventions to keep the actual application code simple to use.
Direct Known Subclasses
Instance Method Summary collapse
-
#arguments ⇒ Hash{Symbol => Mixed}
Prepare the message payload as event method arguments.
-
#consume ⇒ Object
A generic message consuming handler which resolves the message event name to an actual method.
-
#event ⇒ Symbol
A shortcut to fetch the event name from the Kafka message.
Instance Method Details
#arguments ⇒ Hash{Symbol => Mixed}
Prepare the message payload as event method arguments.
19 20 21 |
# File 'lib/rimless/base_consumer.rb', line 19 def arguments params.payload.except(:event) end |
#consume ⇒ Object
A generic message consuming handler which resolves the message event name to an actual method. All message data (top-level keys) is passed down to the event method as symbol arguments.
11 12 13 14 |
# File 'lib/rimless/base_consumer.rb', line 11 def consume # We ignore events we do not handle by definition send(event, **arguments) if respond_to? event end |
#event ⇒ Symbol
A shortcut to fetch the event name from the Kafka message.
26 27 28 |
# File 'lib/rimless/base_consumer.rb', line 26 def event params.payload[:event].to_sym end |