Module: Heartcheck

Defined in:
lib/heartcheck/app.rb,
lib/heartcheck.rb,
lib/heartcheck/logger.rb,
lib/heartcheck/version.rb,
lib/heartcheck/checks/base.rb,
lib/heartcheck/checks/process.rb,
lib/heartcheck/errors/warning.rb,
lib/heartcheck/controllers/dev.rb,
lib/heartcheck/checks/firewall.rb,
lib/heartcheck/controllers/base.rb,
lib/heartcheck/controllers/info.rb,
lib/heartcheck/services/firewall.rb,
lib/heartcheck/generators/generator.rb,
lib/heartcheck/errors/routing_error.rb,
lib/heartcheck/controllers/essential.rb,
lib/heartcheck/controllers/functional.rb,
lib/heartcheck/controllers/health_check.rb

Overview

A web app that's use rack

Defined Under Namespace

Modules: Checks, Controllers, Errors, Services Classes: App, Generator, Logger

Constant Summary collapse

VERSION =
'1.0.3'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.checksObject


13
14
15
# File 'lib/heartcheck.rb', line 13

def checks
  @checks
end

.loggerObject

Is used to log some messages when checking if the logger is not set it's returns de default_logger.

Returns:

  • (Object)

    the logger object


21
22
23
# File 'lib/heartcheck.rb', line 21

def logger
  @logger ||= default_logger
end

Class Method Details

.add(name, options = {}) { ... } ⇒ void

This method returns an undefined value.

It's used to add an instance of a check to the check list

Examples:

Heartcheck.add(:base) do |c|
  c.name = 'Base check'
end

Parameters:

  • name (String)

    to identify in the result page

  • options (Hash) (defaults to: {})

    the options to create an instance of a check.

Options Hash (options):

  • :class (String)

    The class name to get an instance

Yields:

  • a block to config the instance


50
51
52
53
54
55
56
57
58
59
# File 'lib/heartcheck.rb', line 50

def add(name, options = {}, &block)
  class_name = options.fetch(:class) { constantize(name) }
  instance = Checks.const_get(class_name).new

  if block_given?
    checks << instance.tap(&block)
  else
    checks << instance
  end
end

.dev_checksArray<Check>

filter checks that are not functional

Returns:

  • (Array<Check>)

    checks that are not functional


78
79
80
# File 'lib/heartcheck.rb', line 78

def dev_checks
  checks.select { |ctx| !ctx.functional? }
end

.essential_checksArray<Check>

filter checks that are essential

Returns:

  • (Array<Check>)

    checks that are essential


64
65
66
# File 'lib/heartcheck.rb', line 64

def essential_checks
  checks.select { |ctx| !ctx.functional? && !ctx.dev? }
end

.functional_checksArray<Check>

filter checks that are functional

Returns:

  • (Array<Check>)

    checks that are functional


71
72
73
# File 'lib/heartcheck.rb', line 71

def functional_checks
  checks.select(&:functional?)
end

.info_checksArray<Check>

filter checks that has some information

Returns:

  • (Array<Check>)

    checks that respond to :info


85
86
87
# File 'lib/heartcheck.rb', line 85

def info_checks
  checks.select { |ctx| ctx.respond_to?(:info) }
end

.setup { ... } ⇒ void

This method is abstract.

This method returns an undefined value.

Is used to configure.

Examples:

Heartcheck.setup do |c|
  puts c
end

Yields:

  • A bock that recieve the class


34
35
36
# File 'lib/heartcheck.rb', line 34

def setup
  yield(self)
end