Class: Tina4::Consumer
- Inherits:
-
Object
- Object
- Tina4::Consumer
- Defined in:
- lib/tina4/queue.rb
Instance Method Summary collapse
-
#initialize(topic:, backend: nil, max_retries: 3) ⇒ Consumer
constructor
A new instance of Consumer.
- #on_message(&block) ⇒ Object
- #process_one ⇒ Object
- #start(poll_interval: 1) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(topic:, backend: nil, max_retries: 3) ⇒ Consumer
Returns a new instance of Consumer.
57 58 59 60 61 62 63 |
# File 'lib/tina4/queue.rb', line 57 def initialize(topic:, backend: nil, max_retries: 3) @topic = topic @backend = backend || Tina4::QueueBackends::LiteBackend.new @max_retries = max_retries @handlers = [] @running = false end |
Instance Method Details
#on_message(&block) ⇒ Object
65 66 67 |
# File 'lib/tina4/queue.rb', line 65 def (&block) @handlers << block end |
#process_one ⇒ Object
88 89 90 91 |
# File 'lib/tina4/queue.rb', line 88 def process_one = @backend.dequeue(@topic) () if end |