Sha256: 38efce14da013aa6b9a80b3056a3fbec0c6fca86ae412f66b21f387db75d7bb4
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module ConfCtl class HealthChecks::Base # @return [Machine] attr_reader :machine # @return [Array<String>] attr_reader :errors # @param machine [Machine] def initialize(machine) @machine = machine @errors = [] end # @yieldparam [Integer] number of attempts # @yieldparam [Array] errors 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 def successful? @errors.empty? end def description raise NotImplementedError end def message @errors.join('; ') end protected attr_reader :started_at def run_check raise NotImplementedError end def timeout?(_time) true end def cooldown 1 end def add_error(msg) @errors << msg end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
confctl-2.0.0 | lib/confctl/health_checks/base.rb |
confctl-1.0.0 | lib/confctl/health_checks/base.rb |