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
29 30 31 32 |
# File 'lib/gemstash/health.rb', line 29 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
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gemstash/health.rb', line 34 def self.check_db_write Gemstash::Env.current.db.transaction do Gemstash::Env.current.db[:rubygems].insert(name: "health_check:fake_gem_name", created_at: DateTime.now, updated_at: DateTime.now) # We don't want to actually write to the database raise Sequel::Rollback end true end |
.check_storage_read ⇒ Object
16 17 18 19 20 21 |
# File 'lib/gemstash/health.rb', line 16 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
23 24 25 26 27 |
# File 'lib/gemstash/health.rb', line 23 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.
12 13 14 |
# File 'lib/gemstash/health.rb', line 12 def self.heartbeat true end |