Sha256: 0baa2bddd915da9a90857047024a1a69594e952d4be724d3df75876517ba0f97
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'fluent/plugin/out_mongo' module Fluent class MongoOutputReplset < MongoOutput Plugin.register_output('mongo_replset', self) unless method_defined?(:log) define_method(:log) { $log } end config_set_default :include_tag_key, false config_set_default :include_time_key, true desc "Replica set name" config_param :replica_set, :string desc "Read from specified role" config_param :read, :string, :default => nil desc "Retry number" config_param :num_retries, :integer, :default => 60 unless method_defined?(:log) define_method(:log) { $log } end 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 private def operate(client, records) rescue_connection_failure do super(client, records) end end 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-mongo-0.8.0 | lib/fluent/plugin/out_mongo_replset.rb |
fluent-plugin-mongo-0.8.0.rc1 | lib/fluent/plugin/out_mongo_replset.rb |