This processor simply queues up log records for later use.
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.
# 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
Return the oldest record in the record queue, or nil if the record queue is empty.
# File lib/sawmill/record_processor/simple_queue.rb, line 71 def dequeue @queue.dequeue end
Return an array of the contents of the record queue, in order.
# File lib/sawmill/record_processor/simple_queue.rb, line 78 def dequeue_all @queue.dequeue_all end
Return an array of the contents of the extra entry queue, in order.
# File lib/sawmill/record_processor/simple_queue.rb, line 100 def dequeue_all_extra_entries @extra_entries_queue.dequeue_all end
Return the oldest entry in the extra entry queue, or nil if the extra entry queue is empty.
# File lib/sawmill/record_processor/simple_queue.rb, line 93 def dequeue_extra_entry @extra_entries_queue.dequeue end
Return the number of entries in the extra entry queue.
# File lib/sawmill/record_processor/simple_queue.rb, line 107 def extra_entries_size @extra_entries_queue.size end
# File lib/sawmill/record_processor/simple_queue.rb, line 116 def extra_entry(entry_) @extra_entries_queue.enqueue(entry_) unless @closed end
# File lib/sawmill/record_processor/simple_queue.rb, line 120 def finish @closed = true nil end
# File lib/sawmill/record_processor/simple_queue.rb, line 112 def record(record_) @queue.enqueue(record_) unless @closed end
Return the number of records in the record queue.
# File lib/sawmill/record_processor/simple_queue.rb, line 85 def size @queue.size end