Class: LogStash::Codecs::Spool

Inherits:
Base show all
Defined in:
lib/logstash/codecs/spool.rb

Direct Known Subclasses

JsonSpooler

Constant Summary

Constants included from LogStash::Config::Mixin

LogStash::Config::Mixin::CONFIGSORT

Instance Attribute Summary collapse

Attributes included from LogStash::Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#clone, #flush, #initialize, #on_event

Methods included from LogStash::Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #terminating?, #to_s

Constructor Details

This class inherits a constructor from LogStash::Codecs::Base

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



9
10
11
# File 'lib/logstash/codecs/spool.rb', line 9

def buffer
  @buffer
end

Instance Method Details

#decode(data) ⇒ Object



12
13
14
15
16
# File 'lib/logstash/codecs/spool.rb', line 12

def decode(data)
  data.each do |event|
    yield event
  end
end

#encode(data) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# 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

#teardownObject



32
33
34
35
36
37
# File 'lib/logstash/codecs/spool.rb', line 32

def teardown
  if !@buffer.nil? and @buffer.length > 0
    @on_event.call @buffer
  end
  @buffer = []
end