Created
August 9, 2013 10:32
-
-
Save keisuke-kawamura/6192686 to your computer and use it in GitHub Desktop.
pluginの練習w
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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