Class: Gouda::CombinedShutdownCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/gouda/worker.rb

Overview

A wrapping callable which returns ‘true` if any of the given callables return true. This can be used to combine a timed shutdown (“in 30 seconds”) with a signal handler shutdown (“shutdown on SIGTERM/SIGINT”)

Instance Method Summary collapse

Constructor Details

#initialize(*callables_for_condition) ⇒ CombinedShutdownCheck

Returns a new instance of CombinedShutdownCheck.

Parameters:

  • callables_for_condition (#call)

    other shutdown checks



101
102
103
# File 'lib/gouda/worker.rb', line 101

def initialize(*callables_for_condition)
  @conditions = callables_for_condition
end

Instance Method Details

#callObject



105
106
107
108
# File 'lib/gouda/worker.rb', line 105

def call
  # Once one shutdown check told us to shut down there is no point to query all the others
  @memo ||= @conditions.any?(&:call)
end