Class: BBFS::Log::Consumer
- Inherits:
-
Object
- Object
- BBFS::Log::Consumer
- Defined in:
- lib/log/log_consumer.rb
Overview
Base class for all consumers Child consumers must implement the ‘consume’ virtual method
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize ⇒ Consumer
constructor
Initializes the consumer queue and starts a thread.
-
#push_data(data) ⇒ Object
push incoming data to the consumer queue.
Constructor Details
#initialize ⇒ Consumer
Initializes the consumer queue and starts a thread. The thread waits for data on the queue, and when data is popped, activates the virtual ‘consume’ method.
20 21 22 23 24 25 26 27 |
# File 'lib/log/log_consumer.rb', line 20 def initialize @consumer_queue = Queue.new Thread.new do while (true) consume @consumer_queue.pop end end end |
Instance Method Details
#push_data(data) ⇒ Object
push incoming data to the consumer queue
30 31 32 |
# File 'lib/log/log_consumer.rb', line 30 def push_data data @consumer_queue.push data.clone end |