Class: CodecFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/codec_factory.rb

Overview

CodecFactory: lazy-fetch codec plugins

Instance Method Summary collapse

Constructor Details

#initialize(logger, options) ⇒ CodecFactory

Returns a new instance of CodecFactory.



5
6
7
8
9
10
11
12
# File 'lib/logstash/inputs/codec_factory.rb', line 5

def initialize(logger, options)
  @logger = logger
  @default_codec = options[:default_codec]
  @codec_by_folder = options[:codec_by_folder]
  @codecs = {
    'default' => @default_codec
  }
end

Instance Method Details

#get_codec(record) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/logstash/inputs/codec_factory.rb', line 14

def get_codec(record)
  codec = find_codec(record)
  if @codecs[codec].nil?
    @codecs[codec] = get_codec_plugin(codec)
  end
  @logger.debug("Switching to codec #{codec}") if codec != 'default'
  return @codecs[codec].clone
end