Module: Katalyst::Healthcheck::Monitored::ClassMethods

Defined in:
lib/katalyst/healthcheck/monitored.rb

Instance Method Summary collapse

Instance Method Details

#define_healthcheck_task(name, description, interval:) ⇒ Object Also known as: define_task

Define a task to be monitored

Parameters:

  • name (Symbol)

    The name of the task

  • description (String)

    A description of the task’s function

  • interval (Integer, ActiveSupport::Duration)

    Expected frequency that this task runs, e.g. 1.day



15
16
17
# File 'lib/katalyst/healthcheck/monitored.rb', line 15

def define_healthcheck_task(name, description, interval:)
  defined_healthcheck_tasks[name] = Task.new(name: name, description: description, interval: interval)
end

#defined_healthcheck_tasksHash

Returns Defined tasks keyed by name.

Returns:

  • (Hash)

    Defined tasks keyed by name



21
22
23
# File 'lib/katalyst/healthcheck/monitored.rb', line 21

def defined_healthcheck_tasks
  @defined_healthcheck_tasks ||= {}
end

#healthy!(name) ⇒ Object

Mark a task as healthy

Parameters:

  • name (Symbol)

    The name of the task



27
28
29
# File 'lib/katalyst/healthcheck/monitored.rb', line 27

def healthy!(name)
  find_or_create_task(name).healthy!
end

#unhealthy!(name, error = nil) ⇒ Object

Mark a task as unhealthy

Parameters:

  • name (Symbol)

    The name of the task

  • error (String) (defaults to: nil)

    Optional error message



34
35
36
# File 'lib/katalyst/healthcheck/monitored.rb', line 34

def unhealthy!(name, error = nil)
  find_or_create_task(name).unhealthy!(error)
end