Class: ConfCtl::HealthChecks::Base
- Inherits:
-
Object
- Object
- ConfCtl::HealthChecks::Base
show all
- Defined in:
- lib/confctl/health_checks/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(machine) ⇒ Base
Returns a new instance of Base.
10
11
12
13
|
# File 'lib/confctl/health_checks/base.rb', line 10
def initialize(machine)
@machine = machine
@errors = []
end
|
Instance Attribute Details
#errors ⇒ Array<String>
7
8
9
|
# File 'lib/confctl/health_checks/base.rb', line 7
def errors
@errors
end
|
4
5
6
|
# File 'lib/confctl/health_checks/base.rb', line 4
def machine
@machine
end
|
Instance Method Details
#description ⇒ Object
38
39
40
|
# File 'lib/confctl/health_checks/base.rb', line 38
def description
raise NotImplementedError
end
|
#message ⇒ Object
42
43
44
|
# File 'lib/confctl/health_checks/base.rb', line 42
def message
@errors.join('; ')
end
|
#run {|number, errors| ... } ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/confctl/health_checks/base.rb', line 17
def run
@started_at = Time.now
now = @started_at
attempt = 1
until timeout?(now)
@errors.clear
run_check
break if successful?
yield(attempt, errors) if block_given?
sleep(cooldown)
attempt += 1
now = Time.now
end
end
|
#successful? ⇒ Boolean
34
35
36
|
# File 'lib/confctl/health_checks/base.rb', line 34
def successful?
@errors.empty?
end
|