mirror of
https://github.com/mperham/connection_pool
synced 2023-03-27 23:22:21 -04:00
integrate standard
This commit is contained in:
parent
d2ff737ab6
commit
2c927744bb
8 changed files with 14 additions and 10 deletions
3
.standard.yml
Normal file
3
.standard.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
ruby_version: 2.5.0
|
||||||
|
fix: true
|
||||||
|
parallel: true
|
1
Gemfile
1
Gemfile
|
@ -1,3 +1,4 @@
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gemspec(development_group: :runtime)
|
gemspec(development_group: :runtime)
|
||||||
|
gem "standard", group: [:development, :test]
|
||||||
|
|
4
Rakefile
4
Rakefile
|
@ -1,6 +1,6 @@
|
||||||
require "bundler/gem_tasks"
|
require "bundler/gem_tasks"
|
||||||
|
require "standard/rake"
|
||||||
require "rake/testtask"
|
require "rake/testtask"
|
||||||
Rake::TestTask.new
|
Rake::TestTask.new
|
||||||
|
|
||||||
task default: :test
|
task default: [:"standard:fix", :test]
|
||||||
|
|
|
@ -10,9 +10,8 @@ Gem::Specification.new do |s|
|
||||||
s.description = s.summary = "Generic connection pool for Ruby"
|
s.description = s.summary = "Generic connection pool for Ruby"
|
||||||
|
|
||||||
s.files = ["Changes.md", "LICENSE", "README.md", "connection_pool.gemspec",
|
s.files = ["Changes.md", "LICENSE", "README.md", "connection_pool.gemspec",
|
||||||
"lib/connection_pool.rb", "lib/connection_pool/timed_stack.rb",
|
"lib/connection_pool.rb", "lib/connection_pool/timed_stack.rb",
|
||||||
"lib/connection_pool/version.rb", "lib/connection_pool/wrapper.rb"]
|
"lib/connection_pool/version.rb", "lib/connection_pool/wrapper.rb"]
|
||||||
s.test_files = ["test/helper.rb", "test/test_connection_pool.rb", "test/test_connection_pool_timed_stack.rb"]
|
|
||||||
s.executables = []
|
s.executables = []
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
|
|
|
@ -3,7 +3,9 @@ require_relative "connection_pool/version"
|
||||||
|
|
||||||
class ConnectionPool
|
class ConnectionPool
|
||||||
class Error < ::RuntimeError; end
|
class Error < ::RuntimeError; end
|
||||||
|
|
||||||
class PoolShuttingDownError < ::ConnectionPool::Error; end
|
class PoolShuttingDownError < ::ConnectionPool::Error; end
|
||||||
|
|
||||||
class TimeoutError < ::Timeout::Error; end
|
class TimeoutError < ::Timeout::Error; end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -67,7 +69,7 @@ class ConnectionPool
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
alias then with
|
alias_method :then, :with
|
||||||
|
|
||||||
def checkout(options = {})
|
def checkout(options = {})
|
||||||
if ::Thread.current[@key]
|
if ::Thread.current[@key]
|
||||||
|
|
|
@ -49,7 +49,7 @@ class ConnectionPool::TimedStack
|
||||||
@resource.broadcast
|
@resource.broadcast
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
alias << push
|
alias_method :<<, :push
|
||||||
|
|
||||||
##
|
##
|
||||||
# Retrieves a connection from the stack. If a connection is available it is
|
# Retrieves a connection from the stack. If a connection is available it is
|
||||||
|
@ -87,7 +87,7 @@ class ConnectionPool::TimedStack
|
||||||
# +:reload+ is +true+.
|
# +:reload+ is +true+.
|
||||||
|
|
||||||
def shutdown(reload: false, &block)
|
def shutdown(reload: false, &block)
|
||||||
raise ArgumentError, "shutdown must receive a block" unless block_given?
|
raise ArgumentError, "shutdown must receive a block" unless block
|
||||||
|
|
||||||
@mutex.synchronize do
|
@mutex.synchronize do
|
||||||
@shutdown_block = block
|
@shutdown_block = block
|
||||||
|
|
|
@ -30,7 +30,6 @@ class ConnectionPool
|
||||||
METHODS.include?(id) || with { |c| c.respond_to?(id, *args) }
|
METHODS.include?(id) || with { |c| c.respond_to?(id, *args) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Style/MethodMissingSuper
|
|
||||||
# rubocop:disable Style/MissingRespondToMissing
|
# rubocop:disable Style/MissingRespondToMissing
|
||||||
if ::RUBY_VERSION >= "3.0.0"
|
if ::RUBY_VERSION >= "3.0.0"
|
||||||
def method_missing(name, *args, **kwargs, &block)
|
def method_missing(name, *args, **kwargs, &block)
|
||||||
|
|
|
@ -339,7 +339,7 @@ class TestConnectionPool < Minitest::Test
|
||||||
assert_equal 5, pool.do_something_with_block { 3 }
|
assert_equal 5, pool.do_something_with_block { 3 }
|
||||||
assert_equal 6, pool.with { |net| net.fast }
|
assert_equal 6, pool.with { |net| net.fast }
|
||||||
assert_equal 8, pool.do_something(increment: 2)
|
assert_equal 8, pool.do_something(increment: 2)
|
||||||
assert_equal 10, pool.do_something_with_positional_hash({ increment: 2, symbol_key: 3, "string_key" => 4 })
|
assert_equal 10, pool.do_something_with_positional_hash({:increment => 2, :symbol_key => 3, "string_key" => 4})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_passthru_respond_to
|
def test_passthru_respond_to
|
||||||
|
|
Loading…
Reference in a new issue