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



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

def initialize(*callables_for_condition)
  @conditions = callables_for_condition
end

Instance Method Details

#callObject



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

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