class Sawmill::RecordProcessor::SimpleQueue

This processor simply queues up log records for later use.

Public Class Methods

new(opts_={}) click to toggle source

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

Public Instance Methods

dequeue() click to toggle source

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
dequeue_all() click to toggle source

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
dequeue_all_extra_entries() click to toggle source

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
dequeue_extra_entry() click to toggle source

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
extra_entries_size() click to toggle source

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
extra_entry(entry_) click to toggle source
# File lib/sawmill/record_processor/simple_queue.rb, line 116
def extra_entry(entry_)
  @extra_entries_queue.enqueue(entry_) unless @closed
end
finish() click to toggle source
# File lib/sawmill/record_processor/simple_queue.rb, line 120
def finish
  @closed = true
  nil
end
record(record_) click to toggle source
# File lib/sawmill/record_processor/simple_queue.rb, line 112
def record(record_)
  @queue.enqueue(record_) unless @closed
end
size() click to toggle source

Return the number of records in the record queue.

# File lib/sawmill/record_processor/simple_queue.rb, line 85
def size
  @queue.size
end