class Fluent::CouchbaseOutput

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_couchbase.rb, line 22
def configure(conf)
  super

  # perform validations
  raise ConfigError, "'hostname' is required by Couchbase output (ex: localhost)" unless self.hostname
  raise ConfigError, "'port' is required by Couchbase output (ex: 8091)" unless self.port
  raise ConfigError, "'pool' is required by Couchbase output (ex: default)" unless self.pool
  raise ConfigError, "'bucket' is required by Couchbase output (ex: default)" unless self.bucket
  raise ConfigError, "'ttl' is required by Couchbase output (ex: 0)" unless self.ttl
end
connection() click to toggle source
# File lib/fluent/plugin/out_couchbase.rb, line 18
def connection
  @connection ||= get_connection(self.hostname, self.port, self.pool, self.bucket)
end
format(tag, time, record) click to toggle source
# File lib/fluent/plugin/out_couchbase.rb, line 42
def format(tag, time, record)
  record.to_msgpack
end
shutdown() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_couchbase.rb, line 38
def shutdown
  super
end
start() click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_couchbase.rb, line 33
def start
  super
  connection
end
write(chunk) click to toggle source
# File lib/fluent/plugin/out_couchbase.rb, line 46
def write(chunk)
  chunk.msgpack_each  { |record|
    # store ttl in the document itself?
    record[:ttl] = self.ttl if self.include_ttl

    # persist
    connection[record.delete('key'), :ttl => self.ttl] = record
  }
end

Private Instance Methods

get_connection(hostname, port, pool, bucket) click to toggle source
# File lib/fluent/plugin/out_couchbase.rb, line 58
def get_connection(hostname, port, pool, bucket)
  Couchbase.connect(:hostname => hostname,
                    :port => port,
                    :pool => pool,
                    :bucket => bucket)
end