Method: ConnectionPool::TimedStack#shutdown

Defined in:
lib/connection_pool/timed_stack.rb

#shutdown(reload: false, &block) ⇒ Object

Shuts down the TimedStack by passing each connection to block and then removing it from the pool. Attempting to checkout a connection after shutdown will raise ConnectionPool::PoolShuttingDownError unless :reload is true.

Raises:

  • (ArgumentError)


89
90
91
92
93
94
95
96
97
98
99
# File 'lib/connection_pool/timed_stack.rb', line 89

def shutdown(reload: false, &block)
  raise ArgumentError, "shutdown must receive a block" unless block_given?

  @mutex.synchronize do
    @shutdown_block = block
    @resource.broadcast

    shutdown_connections
    @shutdown_block = nil if reload
  end
end