Class: Fluent::CouchOutput

Inherits:
BufferedOutput
  • Object
show all
Includes:
SetTagKeyMixin, SetTimeKeyMixin
Defined in:
lib/fluent/plugin/out_couch.rb

Instance Method Summary collapse

Constructor Details

#initializeCouchOutput

Returns a new instance of CouchOutput.



58
59
60
61
# File 'lib/fluent/plugin/out_couch.rb', line 58

def initialize
    super
    require 'msgpack'
end

Instance Method Details

#configure(conf) ⇒ Object



63
64
65
# File 'lib/fluent/plugin/out_couch.rb', line 63

def configure(conf)
    super
end

#format(tag, time, record) ⇒ Object



77
78
79
# File 'lib/fluent/plugin/out_couch.rb', line 77

def format(tag, time, record)
    record.to_msgpack
end

#shutdownObject



73
74
75
# File 'lib/fluent/plugin/out_couch.rb', line 73

def shutdown
    super
end

#startObject



67
68
69
70
71
# File 'lib/fluent/plugin/out_couch.rb', line 67

def start
    super
    @couch = Couch::Server.new(@host, @port)
    @couch.put(@database, "")
end

#write(chunk) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/fluent/plugin/out_couch.rb', line 81

def write(chunk)
    records = []
    chunk.msgpack_each {|record| records << record }
    @couch.post(@database+'/_bulk_docs', {"all_or_nothing"=>true, "docs"=>records}.to_json)

    #for record in records
    #    @couch.post(@database,record.to_json)
    #end
end