Class: CI::Queue::CircuitBreaker::Timeout

Inherits:
Object
  • Object
show all
Defined in:
lib/ci/queue/circuit_breaker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(duration:) ⇒ Timeout

Returns a new instance of Timeout.



26
27
28
29
30
# File 'lib/ci/queue/circuit_breaker.rb', line 26

def initialize(duration:)
  @duration = duration
  @opened_at = current_timestamp
  @closes_at = @opened_at + duration
end

Instance Attribute Details

#closes_atObject (readonly)

Returns the value of attribute closes_at.



24
25
26
# File 'lib/ci/queue/circuit_breaker.rb', line 24

def closes_at
  @closes_at
end

#durationObject (readonly)

Returns the value of attribute duration.



24
25
26
# File 'lib/ci/queue/circuit_breaker.rb', line 24

def duration
  @duration
end

#opened_atObject (readonly)

Returns the value of attribute opened_at.



24
25
26
# File 'lib/ci/queue/circuit_breaker.rb', line 24

def opened_at
  @opened_at
end

Instance Method Details

#messageObject



42
43
44
# File 'lib/ci/queue/circuit_breaker.rb', line 42

def message
  "This worker is exiting early because it reached its timeout of #{duration} seconds"
end

#open?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/ci/queue/circuit_breaker.rb', line 38

def open?
  closes_at < current_timestamp
end

#report_failure!Object



32
33
# File 'lib/ci/queue/circuit_breaker.rb', line 32

def report_failure!
end

#report_success!Object



35
36
# File 'lib/ci/queue/circuit_breaker.rb', line 35

def report_success!
end