Class: OkComputer::Check
- Inherits:
-
Object
- Object
- OkComputer::Check
- Defined in:
- lib/ok_computer/check.rb
Direct Known Subclasses
ActiveRecordCheck, AppVersionCheck, CacheCheck, DefaultCheck, GenericCacheCheck, HttpCheck, MongoidCheck, MongoidReplicaSetCheck, Neo4jCheck, RabbitmqCheck, RedisCheck, ResqueDownCheck, RubyVersionCheck, SizeThresholdCheck
Constant Summary collapse
- CheckNotDefined =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#failure_occurred ⇒ Object
nil by default, only set to true if the check deems itself failed.
-
#message ⇒ Object
nil by default, set by #check to control the output.
-
#registrant_name ⇒ Object
to be set by Registry upon registration.
Instance Method Summary collapse
-
#clear ⇒ Object
Public: Clear any prior failures.
-
#mark_failure ⇒ Object
Public: Mark that this check has failed in some way.
-
#mark_message(message) ⇒ Object
Public: Capture the desired message to display.
-
#run ⇒ Object
Public: Run the check.
-
#success? ⇒ Boolean
Public: Whether the check passed.
-
#to_json(*args) ⇒ Object
Public: The JSON output of performing the check.
-
#to_text ⇒ Object
Public: The text output of performing the check.
Instance Attribute Details
#failure_occurred ⇒ Object
nil by default, only set to true if the check deems itself failed
6 7 8 |
# File 'lib/ok_computer/check.rb', line 6 def failure_occurred @failure_occurred end |
#message ⇒ Object
nil by default, set by #check to control the output
8 9 10 |
# File 'lib/ok_computer/check.rb', line 8 def @message end |
#registrant_name ⇒ Object
to be set by Registry upon registration
4 5 6 |
# File 'lib/ok_computer/check.rb', line 4 def registrant_name @registrant_name end |
Instance Method Details
#clear ⇒ Object
Public: Clear any prior failures
62 63 64 65 |
# File 'lib/ok_computer/check.rb', line 62 def clear self.failure_occurred = false self. = nil end |
#mark_failure ⇒ Object
Public: Mark that this check has failed in some way
50 51 52 |
# File 'lib/ok_computer/check.rb', line 50 def mark_failure self.failure_occurred = true end |
#mark_message(message) ⇒ Object
Public: Capture the desired message to display
message - Text of the message to display for this check
57 58 59 |
# File 'lib/ok_computer/check.rb', line 57 def () self. = end |
#run ⇒ Object
Public: Run the check
11 12 13 14 |
# File 'lib/ok_computer/check.rb', line 11 def run clear check end |
#success? ⇒ Boolean
Public: Whether the check passed
Returns a boolean
45 46 47 |
# File 'lib/ok_computer/check.rb', line 45 def success? not failure_occurred end |
#to_json(*args) ⇒ Object
Public: The JSON output of performing the check
Returns a String containing JSON
36 37 38 39 40 |
# File 'lib/ok_computer/check.rb', line 36 def to_json(*args) # NOTE swallowing the arguments that Rails passes by default since we don't care. This may prove to be a bad idea # Rails passes stuff like this: {:prefixes=>["ok_computer", "application"], :template=>"show", :layout=>#<Proc>}] {registrant_name => {:message => , :success => success?}}.to_json end |
#to_text ⇒ Object
Public: The text output of performing the check
Returns a String
28 29 30 31 |
# File 'lib/ok_computer/check.rb', line 28 def to_text passfail = success? ? "PASSED" : "FAILED" "#{registrant_name}: #{passfail} #{}" end |