Class: Fluent::KatsubushiFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/fluent/plugin/filter_katsubushi.rb

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



12
13
14
# File 'lib/fluent/plugin/filter_katsubushi.rb', line 12

def configure(conf)
  super
end

#filter(tag, time, record) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/filter_katsubushi.rb', line 25

def filter(tag, time, record)
  tries = 3
  while tries >= 0 do
    begin
      id = @client.get('1', false)
      record[@id_key] = @integer ? id.to_i : id.to_s
    rescue => e
      $log.warn("Couldn't get id from katsubushi: #{e}") if tries == 0
      @client.reset
    ensure
      tries = tries - 1
    end
  end
  record
end

#shutdownObject



21
22
23
# File 'lib/fluent/plugin/filter_katsubushi.rb', line 21

def shutdown
  super
end

#startObject



16
17
18
19
# File 'lib/fluent/plugin/filter_katsubushi.rb', line 16

def start
  super
  @client = ::Memcached.new(["#{@host}:#{@port}"])
end