Class: YAKC::Reader
- Inherits:
-
Object
- Object
- YAKC::Reader
- Defined in:
- lib/yakc/reader.rb
Instance Attribute Summary collapse
-
#message_handler ⇒ Object
readonly
Returns the value of attribute message_handler.
-
#terminated ⇒ Object
readonly
Returns the value of attribute terminated.
Instance Method Summary collapse
-
#initialize(message_handler:) ⇒ Reader
constructor
A new instance of Reader.
- #read ⇒ Object
Constructor Details
#initialize(message_handler:) ⇒ Reader
Returns a new instance of Reader.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/yakc/reader.rb', line 5 def initialize( message_handler: ) @message_handler = @config = YAKC.configuration raise KeyError, "YAKC::Reader initialized without a message handler. Please specify one so that your receives messages don't end up on the floor. For more info, go to: https://github.com/gaorlov/yakc#message-handler" unless Signal.trap("INT") do @terminated = true end end |
Instance Attribute Details
#message_handler ⇒ Object (readonly)
Returns the value of attribute message_handler.
3 4 5 |
# File 'lib/yakc/reader.rb', line 3 def @message_handler end |
#terminated ⇒ Object (readonly)
Returns the value of attribute terminated.
3 4 5 |
# File 'lib/yakc/reader.rb', line 3 def terminated @terminated end |
Instance Method Details
#read ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/yakc/reader.rb', line 16 def read loop do consumers.map do |consumer| consumer.fetch do |partition, bulk| bulk.each do || .handle topic, end end return if terminated end end rescue => e YACK.logger.error e retry end |