class LogStash::Codecs::Spool

Attributes

buffer[R]

Public Instance Methods

decode(data) { |event| ... } click to toggle source
# File lib/logstash/codecs/spool.rb, line 12
def decode(data)
  data.each do |event|
    yield event
  end
end
encode(data) click to toggle source
# File lib/logstash/codecs/spool.rb, line 19
def encode(data)
  @buffer = [] if @buffer.nil?
  #buffer size is hard coded for now until a
  #better way to pass args into codecs is implemented
  if @buffer.length >= @spool_size
    @on_event.call @buffer
    @buffer = []
  else
    @buffer << data
  end
end
teardown() click to toggle source
# File lib/logstash/codecs/spool.rb, line 32
def teardown
  if !@buffer.nil? and @buffer.length > 0
    @on_event.call @buffer
  end
  @buffer = []
end