module Gemstash::Health
This module contains the logic used to supply a health monitor for Gemstash
. You can access the health monitor at the /health endpoint.
Constants
- RackMiddleware
Public Class Methods
check_db_read()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
This check can be used if you don’t want to read or write content during a health check.
# File lib/gemstash/health.rb, line 14 def self.heartbeat true end