Class: Fluent::CouchOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::CouchOutput
- Includes:
- SetTimeKeyMixin
- Defined in:
- lib/fluent/plugin/out_couch.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ CouchOutput
constructor
A new instance of CouchOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ CouchOutput
Returns a new instance of CouchOutput.
53 54 55 56 |
# File 'lib/fluent/plugin/out_couch.rb', line 53 def initialize super require 'msgpack' end |
Instance Method Details
#configure(conf) ⇒ Object
58 59 60 |
# File 'lib/fluent/plugin/out_couch.rb', line 58 def configure(conf) super end |
#format(tag, time, record) ⇒ Object
72 73 74 |
# File 'lib/fluent/plugin/out_couch.rb', line 72 def format(tag, time, record) record.to_msgpack end |
#shutdown ⇒ Object
68 69 70 |
# File 'lib/fluent/plugin/out_couch.rb', line 68 def shutdown super end |
#start ⇒ Object
62 63 64 65 66 |
# File 'lib/fluent/plugin/out_couch.rb', line 62 def start super @couch = Couch::Server.new(@host, @port) @couch.put(@database, "") end |
#write(chunk) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fluent/plugin/out_couch.rb', line 76 def write(chunk) records = [] chunk.open { |io| begin MessagePack::Unpacker.new(io).each { |record| records << record } rescue EOFError # EOFError always occured when reached end of chunk. end } #TODO: bulk insert for record in records @couch.post(@database,record.to_json) end end |