Class: NulogyMessageBusConsumer::Steps::StreamMessagesUntilNoneAreLeft
- Inherits:
-
Object
- Object
- NulogyMessageBusConsumer::Steps::StreamMessagesUntilNoneAreLeft
- Defined in:
- lib/nulogy_message_bus_consumer/steps/stream_messages_until_none_are_left.rb
Instance Method Summary collapse
- #call(kafka_consumer:, **_) ⇒ Object
-
#initialize(logger, timeout = 250) ⇒ StreamMessagesUntilNoneAreLeft
constructor
A new instance of StreamMessagesUntilNoneAreLeft.
Constructor Details
#initialize(logger, timeout = 250) ⇒ StreamMessagesUntilNoneAreLeft
Returns a new instance of StreamMessagesUntilNoneAreLeft.
4 5 6 7 |
# File 'lib/nulogy_message_bus_consumer/steps/stream_messages_until_none_are_left.rb', line 4 def initialize(logger, timeout = 250) @logger = logger @timeout = timeout end |
Instance Method Details
#call(kafka_consumer:, **_) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nulogy_message_bus_consumer/steps/stream_messages_until_none_are_left.rb', line 9 def call(kafka_consumer:, **_) KafkaUtils.(kafka_consumer, @timeout).each do || result = yield( message: Message.from_kafka(), kafka_message: ) if result == :failure # stop reading on failure or else we'll get stuck in a loop return :failure end end :success rescue => e @logger.error(JSON.dump({ event: "message_processing_errored", class: e.class, message: e. })) raise end |