Class: Sawmill::RecordProcessor::SimpleQueue
- Defined in:
- lib/sawmill/record_processor/simple_queue.rb
Overview
This processor simply queues up log records for later use.
Instance Method Summary collapse
-
#dequeue ⇒ Object
Return the oldest record in the record queue, or nil if the record queue is empty.
-
#dequeue_all ⇒ Object
Return an array of the contents of the record queue, in order.
-
#dequeue_all_extra_entries ⇒ Object
Return an array of the contents of the extra entry queue, in order.
-
#dequeue_extra_entry ⇒ Object
Return the oldest entry in the extra entry queue, or nil if the extra entry queue is empty.
-
#extra_entries_size ⇒ Object
Return the number of entries in the extra entry queue.
- #extra_entry(entry_) ⇒ Object
- #finish ⇒ Object
-
#initialize(opts_ = {}) ⇒ SimpleQueue
constructor
Create a queue.
- #record(record_) ⇒ Object
-
#size ⇒ Object
Return the number of records in the record queue.
Methods inherited from Base
Constructor Details
#initialize(opts_ = {}) ⇒ SimpleQueue
Create a queue. This processor actually maintains two separate queues, one for records and another for extra entries.
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.
61 62 63 64 65 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 61 def initialize(opts_={}) @queue = Util::Queue.new(opts_) @extra_entries_queue = Util::Queue.new(opts_) @closed = false end |
Instance Method Details
#dequeue ⇒ Object
Return the oldest record in the record queue, or nil if the record queue is empty.
71 72 73 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 71 def dequeue @queue.dequeue end |
#dequeue_all ⇒ Object
Return an array of the contents of the record queue, in order.
78 79 80 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 78 def dequeue_all @queue.dequeue_all end |
#dequeue_all_extra_entries ⇒ Object
Return an array of the contents of the extra entry queue, in order.
100 101 102 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 100 def dequeue_all_extra_entries @extra_entries_queue.dequeue_all end |
#dequeue_extra_entry ⇒ Object
Return the oldest entry in the extra entry queue, or nil if the extra entry queue is empty.
93 94 95 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 93 def dequeue_extra_entry @extra_entries_queue.dequeue end |
#extra_entries_size ⇒ Object
Return the number of entries in the extra entry queue.
107 108 109 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 107 def extra_entries_size @extra_entries_queue.size end |
#extra_entry(entry_) ⇒ Object
116 117 118 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 116 def extra_entry(entry_) @extra_entries_queue.enqueue(entry_) unless @closed end |
#finish ⇒ Object
120 121 122 123 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 120 def finish @closed = true nil end |
#record(record_) ⇒ Object
112 113 114 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 112 def record(record_) @queue.enqueue(record_) unless @closed end |
#size ⇒ Object
Return the number of records in the record queue.
85 86 87 |
# File 'lib/sawmill/record_processor/simple_queue.rb', line 85 def size @queue.size end |