Class: EventHub::MessageProcessor
- Inherits:
-
Object
- Object
- EventHub::MessageProcessor
- Defined in:
- lib/eventhub/message_processor.rb
Instance Attribute Summary collapse
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Instance Method Summary collapse
-
#initialize(processor) ⇒ MessageProcessor
constructor
A new instance of MessageProcessor.
- #process(params, payload) ⇒ Object
Constructor Details
#initialize(processor) ⇒ MessageProcessor
Returns a new instance of MessageProcessor.
4 5 6 |
# File 'lib/eventhub/message_processor.rb', line 4 def initialize(processor) @processor = processor end |
Instance Attribute Details
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
2 3 4 |
# File 'lib/eventhub/message_processor.rb', line 2 def processor @processor end |
Instance Method Details
#process(params, payload) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/eventhub/message_processor.rb', line 8 def process(params, payload) = [] # try to convert to EventHub message = EventHub::Message.from_json(payload) EventHub.logger.info("-> #{.to_s}") .append_to_execution_history(self.processor.name) if .invalid? << EventHub.logger.info("-> #{.to_s} => Put to queue [#{EventHub::EH_X_INBOUND}].") else # pass received message to handler or dervied handler if processor.method(:handle_message).arity == 1 = Array(processor.()) else = Array(processor.(,params)) end end end |