Module: Gemstash::Health
- Defined in:
- lib/gemstash/health.rb
Overview
This module contains the logic used to supply a health monitor for Gemstash. You can access the health monitor at the /health endpoint.
Constant Summary collapse
- RackMiddleware =
ServerHealthCheckRack::Middleware
Class Method Summary collapse
- .check_db_read ⇒ Object
- .check_db_write ⇒ Object
- .check_storage_read ⇒ Object
- .check_storage_write ⇒ Object
-
.heartbeat ⇒ Object
This check can be used if you don’t want to read or write content during a health check.
Class Method Details
.check_db_read ⇒ Object
31 32 33 34 |
# File 'lib/gemstash/health.rb', line 31 def self.check_db_read result = Gemstash::Env.current.db[:rubygems].where(name: "testing_db_read").count result.is_a?(Numeric) end |
.check_db_write ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gemstash/health.rb', line 36 def self.check_db_write Gemstash::Env.current.db.transaction do health_tests = Gemstash::Env.current.db[:health_tests] health_tests.truncate health_tests.insert(string: "test_string") # We don't want to actually write to the database raise Sequel::Rollback end true end |
.check_storage_read ⇒ Object
18 19 20 21 22 23 |
# File 'lib/gemstash/health.rb', line 18 def self.check_storage_read if check_storage_write content = Gemstash::Storage.for("health").resource("test").content(:example) content =~ /\Acontent-\d+\z/ end end |
.check_storage_write ⇒ Object
25 26 27 28 29 |
# File 'lib/gemstash/health.rb', line 25 def self.check_storage_write resource = Gemstash::Storage.for("health").resource("test") resource.save(example: "content-#{Time.now.to_i}") true end |
.heartbeat ⇒ Object
This check can be used if you don’t want to read or write content during a health check.
14 15 16 |
# File 'lib/gemstash/health.rb', line 14 def self.heartbeat true end |