Module: Fluent::MongoUtil

Included in:
MongoOutput, MongoTailInput
Defined in:
lib/fluent/plugin/mongo_util.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
10
# File 'lib/fluent/plugin/mongo_util.rb', line 5

def self.included(klass)
  klass.instance_eval {
    config_param :user, :string, :default => nil
    config_param :password, :string, :default => nil, :secret => true
  }
end

Instance Method Details

#authenticate(db) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fluent/plugin/mongo_util.rb', line 12

def authenticate(db)
  unless @user.nil? || @password.nil?
    begin
      db.authenticate(@user, @password)
    rescue Mongo::AuthenticationError => e
      log.fatal e
      exit!
    end
  end

  db
end