Class: Sawmill::EntryProcessor::SimpleQueue
- Defined in:
- lib/sawmill/entry_processor/simple_queue.rb
Overview
This processor simply queues up log entries for later use.
Instance Method Summary collapse
- #attribute(entry_) ⇒ Object
- #begin_record(entry_) ⇒ Object
-
#dequeue ⇒ Object
Return the oldest entry in the queue, or nil if the queue is empty.
-
#dequeue_all ⇒ Object
Return an array of the contents of the queue, in order.
- #end_record(entry_) ⇒ Object
- #finish ⇒ Object
-
#initialize(opts_ = {}) ⇒ SimpleQueue
constructor
Create a queue.
- #message(entry_) ⇒ Object
-
#size ⇒ Object
Return the size of the queue, which is 0 if the queue is empty.
- #unknown_data(entry_) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(opts_ = {}) ⇒ SimpleQueue
Create a queue.
Recognized options include:
:limit-
Size limit for the queue. If not specified, the queue can grow arbitrarily large.
:drop_oldest-
If set to true, then when an item is added to a full queue, the oldest item is dropped. If set to false or not specified, then the new item is not added.
60 61 62 63 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 60 def initialize(opts_={}) @queue = Util::Queue.new(opts_) @closed = false end |
Instance Method Details
#attribute(entry_) ⇒ Object
102 103 104 105 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 102 def attribute(entry_) @queue.enqueue(entry_) unless @closed !@closed end |
#begin_record(entry_) ⇒ Object
87 88 89 90 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 87 def begin_record(entry_) @queue.enqueue(entry_) unless @closed !@closed end |
#dequeue ⇒ Object
Return the oldest entry in the queue, or nil if the queue is empty.
68 69 70 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 68 def dequeue @queue.dequeue end |
#dequeue_all ⇒ Object
Return an array of the contents of the queue, in order.
75 76 77 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 75 def dequeue_all @queue.dequeue_all end |
#end_record(entry_) ⇒ Object
92 93 94 95 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 92 def end_record(entry_) @queue.enqueue(entry_) unless @closed !@closed end |
#finish ⇒ Object
112 113 114 115 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 112 def finish @closed = true nil end |
#message(entry_) ⇒ Object
97 98 99 100 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 97 def (entry_) @queue.enqueue(entry_) unless @closed !@closed end |
#size ⇒ Object
Return the size of the queue, which is 0 if the queue is empty.
82 83 84 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 82 def size @queue.size end |
#unknown_data(entry_) ⇒ Object
107 108 109 110 |
# File 'lib/sawmill/entry_processor/simple_queue.rb', line 107 def unknown_data(entry_) @queue.enqueue(entry_) unless @closed !@closed end |