Class: MiddlewareHealthcheck::DefaultCheckers::ActiveRecordChecker
- Inherits:
-
Object
- Object
- MiddlewareHealthcheck::DefaultCheckers::ActiveRecordChecker
- Defined in:
- lib/middleware_healthcheck/default_checkers/active_record_checker.rb
Constant Summary collapse
- NOT_CONNECTED_ERROR =
"Can't connect to database.".freeze
- EXCEPTION_REGEXP =
/^ActiveRecord::/.freeze
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
Instance Method Summary collapse
- #healthy? ⇒ Boolean
-
#initialize(_app, _env) ⇒ ActiveRecordChecker
constructor
A new instance of ActiveRecordChecker.
Constructor Details
#initialize(_app, _env) ⇒ ActiveRecordChecker
Returns a new instance of ActiveRecordChecker.
9 10 |
# File 'lib/middleware_healthcheck/default_checkers/active_record_checker.rb', line 9 def initialize(_app, _env) end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
7 8 9 |
# File 'lib/middleware_healthcheck/default_checkers/active_record_checker.rb', line 7 def error @error end |
Instance Method Details
#healthy? ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/middleware_healthcheck/default_checkers/active_record_checker.rb', line 12 def healthy? ActiveRecord::Base.establish_connection ActiveRecord::Base.connection if ActiveRecord::Base.connected? true else self.error = NOT_CONNECTED_ERROR false end rescue => e if e.class.to_s.match EXCEPTION_REGEXP self.error = e. false else raise e end end |