class Fluent::Plugin::MongoOutputReplset

Public Instance Methods

configure(conf) click to toggle source
Calls superclass method Fluent::Plugin::MongoOutput#configure
# File lib/fluent/plugin/out_mongo_replset.rb, line 19
def configure(conf)
  super

  if replica_set = conf['replica_set']
    @client_options[:replica_set] = replica_set
  end
  if read = conf['read']
    @client_options[:read] = read.to_sym
  end

  log.debug "Setup replica set configuration: #{conf['replica_set']}"
end
write(chunk) click to toggle source
Calls superclass method Fluent::Plugin::MongoOutput#write
# File lib/fluent/plugin/out_mongo_replset.rb, line 32
def write(chunk)
  super
end

Private Instance Methods

operate(database, client, records) click to toggle source
Calls superclass method Fluent::Plugin::MongoOutput#operate
# File lib/fluent/plugin/out_mongo_replset.rb, line 38
def operate(database, client, records)
  rescue_connection_failure do
    super(database, client, records)
  end
end
rescue_connection_failure() { || ... } click to toggle source
# File lib/fluent/plugin/out_mongo_replset.rb, line 44
def rescue_connection_failure
  retries = 0
  begin
    yield
  rescue Mongo::Error::OperationFailure => e
    retries += 1
    raise e if retries > @num_retries

    log.warn "Failed to operate to Replica Set. Try to retry: retry count = #{retries}"

    sleep 0.5
    retry
  end
end