Class: Philae::MongoProbe

Inherits:
Object
  • Object
show all
Defined in:
lib/philae/mongo_probe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, uri) ⇒ MongoProbe

Returns a new instance of MongoProbe.



9
10
11
12
# File 'lib/philae/mongo_probe.rb', line 9

def initialize(name, uri)
  @name = name
  @uri = uri
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/philae/mongo_probe.rb', line 7

def name
  @name
end

Instance Method Details

#checkObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/philae/mongo_probe.rb', line 14

def check
  begin
    @client ||= Mongo::Client.new(@uri, max_read_retries: 1)
    db = @client.database
    db.collection_names
    @client.close
  rescue
    return { healthy: false, comment: 'Unable to contact mongo' }
  end

  return { healthy: true, comment: '' }
end