Module: Rapporteur

Defined in:
lib/rapporteur.rb,
lib/rapporteur/checks.rb,
lib/rapporteur/engine.rb,
lib/rapporteur/checker.rb,
lib/rapporteur/version.rb,
lib/rapporteur/revision.rb,
lib/rapporteur/responder.rb,
lib/rapporteur/checker_deprecations.rb,
lib/rapporteur/checks/active_record_check.rb

Overview

Rapporteur is a Rails Engine which provides your application with an application status endpoint.

Defined Under Namespace

Modules: CheckerDeprecations, Checks Classes: Checker, Engine, Responder, Revision

Constant Summary collapse

VERSION =
"2.0.1"

Class Method Summary collapse

Class Method Details

.add_check(object_or_nil_with_block = nil, &block) ⇒ Object

Public: Add a pre-built or custom check to your status endpoint. These checks are used to test the state of the world of the application, and need only respond to ‘#call`.

Once added, the given check will be called and passed an instance of this checker. If everything is good, do nothing! If there is a problem, use ‘add_error` to add an error message to the checker.

Examples

Rapporteur.add_check { |checker|
  checker.add_error("Bad luck.") if rand(2) == 1
}

Returns the Checker instance. Raises ArgumentError if the given check does not respond to call.



32
33
34
# File 'lib/rapporteur.rb', line 32

def self.add_check(object_or_nil_with_block=nil, &block)
  checker.add_check(object_or_nil_with_block, &block)
end

.checkerObject

Internal: The Checker instance. All toplevel calls on Rapporteur are delgated to this object.



39
40
41
42
43
44
45
46
# File 'lib/rapporteur.rb', line 39

def self.checker
  unless @checker
    @checker = Checker.new
    add_check(Checks::RevisionCheck)
    add_check(Checks::TimeCheck)
  end
  @checker
end

.clear_checksObject

Public: Empties all configured checks from the checker. This may be useful for testing and for cases where you might’ve built up some basic checks but for one reason or another (environment constraint) need to start from scratch.

Returns the Checker instance.



55
56
57
# File 'lib/rapporteur.rb', line 55

def self.clear_checks
  checker.clear
end

.runObject

Public: This is the primary execution point for this class. Use run to exercise the configured checker and collect any application errors or data for rendering.

Returns the Checker instance.



65
66
67
# File 'lib/rapporteur.rb', line 65

def self.run
  checker.run
end