Method: Sequel::ShardedTimedQueueConnectionPool#disconnect
- Defined in:
- lib/sequel/connection_pool/sharded_timed_queue.rb
#disconnect(opts = OPTS) ⇒ Object
Removes all connections currently in the pool’s queue. This method has the effect of disconnecting from the database, assuming that no connections are currently being used.
Once a connection is requested using #hold, the connection pool creates new connections to the database.
If the :server option is provided, it should be a symbol or array of symbols, and then the method will only disconnect connectsion from those specified shards.
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/sequel/connection_pool/sharded_timed_queue.rb', line 95 def disconnect(opts=OPTS) (opts[:server] ? Array(opts[:server]) : sync{@servers.keys}).each do |server| raise Sequel::Error, "invalid server" unless queue = sync{@queues[server]} while conn = queue.pop(timeout: 0) disconnect_pool_connection(conn, server) end fill_queue(server) end nil end |