1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
class ConnectionPool
class Wrapper < ::BasicObject
METHODS = [:with, :pool_shutdown, :wrapped_pool]
def initialize(**options, &)
@pool = options.fetch(:pool) { ::ConnectionPool.new(**options, &) }
end
def wrapped_pool
@pool
end
def with(**, &)
@pool.with(**, &)
end
def pool_shutdown(&)
@pool.shutdown(&)
end
def pool_size
@pool.size
end
def pool_available
@pool.available
end
def respond_to?(id, *, **)
METHODS.include?(id) || with { |c| c.respond_to?(id, *, **) }
end
def respond_to_missing?(id, *, **)
with { |c| c.respond_to?(id, *, **) }
end
def method_missing(name, *, **, &)
with do |connection|
connection.send(name, *, **, &)
end
end
end
end
|