Sha256: ddc167814552777a2da24b79eeaa637a8f157818755baeaa6aae5c0a792d1929
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
# frozen-string-literal: true # This is the fastest connection pool, since it isn't a connection pool at all. # It is just a wrapper around a single connection that uses the connection pool # API. class Sequel::SingleConnectionPool < Sequel::ConnectionPool def initialize(db, opts=OPTS) super @conn = [] end # Yield the connection if one has been made. def all_connections yield @conn.first if @conn end # Disconnect the connection from the database. def disconnect(opts=nil) return unless c = @conn.first disconnect_connection(c) @conn.clear nil end # Yield the connection to the block. def hold(server=nil) begin unless c = @conn.first @conn.replace([c = make_new(:default)]) end yield c rescue Sequel::DatabaseDisconnectError, *@error_classes => e disconnect if disconnect_error?(e) raise end end # The SingleConnectionPool always has a maximum size of 1. def max_size 1 end def pool_type :single end # The SingleConnectionPool always has a size of 1 if connected # and 0 if not. def size @conn.empty? ? 0 : 1 end private # Make sure there is a valid connection. def preconnect(concurrent = nil) hold{} end CONNECTION_POOL__MAP[[true, false]] = self end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sequel-4.49.0 | lib/sequel/connection_pool/single.rb |