pools 1.2.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34f31d2ae9607c1157db230bcb465c9f8a53c471c7308fd7e8c37a4f218fb13c
4
- data.tar.gz: 9c1727c836239fca1a527f8b292cad8ad14ddfd0a5befac773392b3b80b3c741
3
+ metadata.gz: e8d3e82dd40029537c45fb4a6ce5d3fb19a76288996a61922e77fb12799565ed
4
+ data.tar.gz: bf0de9aed6d5dd20be76bbc1771e8a210a588e62e3df26a5b2ef1505be7fa676
5
5
  SHA512:
6
- metadata.gz: dae2b78c89af30a3447a76cc89c6f3d7f60f9a3ea24d53789f30cbf2b97447f18f2d5878085ad5411210d97a80dba0679852285acd93c1ce79720fc7ddd3f704
7
- data.tar.gz: 3a0ce250ef1ec98c0169361d701cfb7442359d645de8cd3647c8be5ba13927cae6d0435ae1ff54ed221d6a9f14596d767c807abb8216b7177aaf52740af8bd9a
6
+ metadata.gz: d4fa66a2fd9ed7e73781bd42178753291c429e3fa2936569ce8272b041240e5a72934a84b88f9ee434c12e3b8c28ec6f0a1fd61e089e80c8fa82ac4883db7e84
7
+ data.tar.gz: fe4f7bfa86d21b4c745a04a8f984ff0df4602a72affdaf59feec29d60ecc36d0ae5ff1c5661094542ded442852996bec440d6363798915e3f9804f84b68af611
data/README.md CHANGED
@@ -2,7 +2,7 @@ Pools - Reusable Connection Pooling
2
2
  -----------------------------------
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/pools.svg)](https://badge.fury.io/rb/pools)
5
- [![Build Status](https://travis-ci.org/rykov/pools.svg)](https://travis-ci.org/rykov/pools)
5
+ [![Build Status](https://github.com/rykov/pools/actions/workflows/specs.yml/badge.svg)](https://github.com/rykov/pools/actions/workflows/specs.yml)
6
6
 
7
7
  Provides connection pooling for multiple services that
8
8
  use persistent connections
@@ -83,7 +83,7 @@ module Pools
83
83
  @timeout = options[:wait_timeout] || 5
84
84
 
85
85
  # default max pool size to 5
86
- @size = (options[:pool] && options[:pool].to_i) || 5
86
+ @size = (@options.delete(:pool) || 5).to_i
87
87
 
88
88
  @connections = []
89
89
  @checked_out = []
data/lib/pools/handler.rb CHANGED
@@ -12,7 +12,9 @@ module Pools
12
12
 
13
13
  # Add a new connection pool to the mix
14
14
  def add(pool, name = nil)
15
- @pools[name || pool.object_id] = pool
15
+ key = name || pool.object_id
16
+ raise(%Q(Pool "#{name}" already exists)) if @pools[name]
17
+ @pools[name] = pool
16
18
  end
17
19
 
18
20
  # Returns any connections in use by the current thread back to the
data/lib/pools/pooled.rb CHANGED
@@ -8,9 +8,11 @@ module Pools
8
8
 
9
9
  def initialize(*args)
10
10
  options = args.extract_options!
11
+ pool_name = options.delete(:pool_name)
12
+
11
13
  @preparation_chain = []
12
14
  @connection_pool = ConnectionPool.new(self, options)
13
- Pools.handler.add(@connection_pool, options[:pool_name])
15
+ Pools.handler.add(@connection_pool, pool_name)
14
16
  end
15
17
 
16
18
  def with_connection(&block)
@@ -32,9 +34,15 @@ module Pools
32
34
  module ClassMethods
33
35
  def connection_methods(*methods)
34
36
  methods.each do |method|
35
- define_method(method) do |*params, &block|
37
+ define_method(method) do |*args, **kwargs, &block|
36
38
  with_connection do |client|
37
- client.send(method, *params, &block)
39
+ # https://bugs.ruby-lang.org/issues/14415
40
+ # Needed for pre-2.5 Ruby support
41
+ if !kwargs.empty?
42
+ client.send(method, *args, **kwargs, &block)
43
+ else
44
+ client.send(method, *args, &block)
45
+ end
38
46
  end
39
47
  end
40
48
  end
@@ -49,4 +57,4 @@ module Pools
49
57
  end
50
58
  end
51
59
  end
52
- end
60
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Rykov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-07 00:00:00.000000000 Z
11
+ date: 2023-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport