class DeepHealthCheck::DependencyHealthCheck

Public Class Methods

new() click to toggle source
# File lib/deep_health_check/dependency_health_check.rb, line 5
def initialize
  @type = 'abstract'
  @dependencies = nil
  raise 'You are trying to instantiate an abstract class!'
end

Public Instance Methods

call() click to toggle source
# File lib/deep_health_check/dependency_health_check.rb, line 11
def call
  return no_dependencies_response if @dependencies.nil?
  api_health_check health_status_code, @dependencies
end

Private Instance Methods

fetch_dependencies_from_env() click to toggle source
# File lib/deep_health_check/dependency_health_check.rb, line 26
def fetch_dependencies_from_env
  dependencies = []
  (0..99).each do |i|
    dependencies << ENV[format("#{@type.upcase}_DEPENDENCY_%02d", i)]
  end
  dependencies.compact
end
health_status_code() click to toggle source
# File lib/deep_health_check/dependency_health_check.rb, line 18
def health_status_code
  raise 'health_status_code need to implmented'
end
no_dependencies_response() click to toggle source
# File lib/deep_health_check/dependency_health_check.rb, line 22
def no_dependencies_response
  api_health_check 200, 'message': "No #{@type.upcase} dependencies defined"
end