Class: Kafka::AsyncProducer::Timer
- Inherits:
-
Object
- Object
- Kafka::AsyncProducer::Timer
- Defined in:
- lib/kafka/async_producer.rb
Instance Method Summary collapse
-
#initialize(interval:, queue:) ⇒ Timer
constructor
A new instance of Timer.
- #run ⇒ Object
Constructor Details
#initialize(interval:, queue:) ⇒ Timer
Returns a new instance of Timer.
162 163 164 165 |
# File 'lib/kafka/async_producer.rb', line 162 def initialize(interval:, queue:) @queue = queue @interval = interval end |
Instance Method Details
#run ⇒ Object
167 168 169 170 171 172 173 174 175 |
# File 'lib/kafka/async_producer.rb', line 167 def run # Permanently sleep if the timer interval is zero. Thread.stop if @interval.zero? loop do sleep(@interval) @queue << [:deliver_messages, nil] end end |