Skip to content

Instantly share code, notes, and snippets.

@kkawamura
Created August 9, 2013 10:32
Show Gist options
  • Save kkawamura/6192686 to your computer and use it in GitHub Desktop.
Save kkawamura/6192686 to your computer and use it in GitHub Desktop.
pluginの練習w
module Fluent
class RomaOutput < BufferedOutput
Fluent::Plugin.register_output('roma', self)
#config_param :host, :string, :default => 'localhost'
def initialize
super
require 'roma/client'
end
def configure(conf)
super
nodelist = "localhost:1111,localhost:1112"
@nodes = nodelist.split ','
end
def start
super
@roma = Roma::Client::RomaClient.new(@nodes)
end
def shutdown
super
@roma = nil
end
def format(tag, time, record)
[tag, time, record].to_msgpack
end
def write(chunk)
begin
chunk.msgpack_each do |(tag, time, rec)|
@roma.set "#{tag}:#{time}", "#{rec}"
end
rescue EOFError
# EOF Error always occured whern reachd end of chunk.
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment