sequel_fresh_connections 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- # Fresh Connections
1
+ = Fresh Connections
2
2
 
3
3
  The fresh_connections extension removes stale connections from the connection
4
4
  pool, ensuring any connections that have timed out won't be used.
@@ -15,3 +15,10 @@ removed from the pool.
15
15
 
16
16
  Each time a connection is used its age is reset, so as long as connections are
17
17
  in constant use they will not be removed from the pool.
18
+
19
+ == Sequel version compatibility
20
+
21
+ sequel | sequel_fresh_connections
22
+ ----------+-------------------------
23
+ <= 3.40.0 | 0.1.0
24
+ >= 3.41.0 | 0.2.0
@@ -2,7 +2,7 @@ Sequel.require 'connection_pool/sharded_single'
2
2
 
3
3
  class Sequel::FreshShardedSingleConnectionPool < Sequel::ShardedSingleConnectionPool
4
4
 
5
- def initialize(opts={})
5
+ def initialize(db, opts={})
6
6
  super
7
7
  @max_connection_age = opts[:max_connection_age] || 1800 # 30 mins
8
8
  @last_uses = {}
@@ -13,12 +13,12 @@ class Sequel::FreshShardedSingleConnectionPool < Sequel::ShardedSingleConnection
13
13
  server = pick_server(server)
14
14
  conn_age = @last_uses[server] ? Time.now.to_i - @last_uses[server] : 0
15
15
  if conn_age > @max_connection_age
16
- disconnect_server(server, &@disconnection_proc)
16
+ disconnect_server(server)
17
17
  end
18
18
  @last_uses[server] = Time.now.to_i
19
19
  yield(@conns[server] ||= make_new(server))
20
20
  rescue Sequel::DatabaseDisconnectError
21
- disconnect_server(server, &@disconnection_proc)
21
+ disconnect_server(server)
22
22
  raise
23
23
  end
24
24
  end
@@ -2,7 +2,7 @@ Sequel.require 'connection_pool/sharded_threaded'
2
2
 
3
3
  class Sequel::FreshShardedThreadedConnectionPool < Sequel::ShardedThreadedConnectionPool
4
4
 
5
- def initialize(opts={})
5
+ def initialize(db, opts={})
6
6
  super
7
7
  @max_connection_age = opts[:max_connection_age] || 1800 # 30 mins
8
8
  @last_uses = {}
@@ -2,7 +2,7 @@ Sequel.require 'connection_pool/single'
2
2
 
3
3
  class Sequel::FreshSingleConnectionPool < Sequel::SingleConnectionPool
4
4
 
5
- def initialize(opts={})
5
+ def initialize(db, opts={})
6
6
  super
7
7
  @max_connection_age = opts[:max_connection_age] || 1800 # 30 mins
8
8
  @last_use = nil
@@ -2,7 +2,7 @@ Sequel.require 'connection_pool/threaded'
2
2
 
3
3
  class Sequel::FreshThreadedConnectionPool < Sequel::ThreadedConnectionPool
4
4
 
5
- def initialize(opts={})
5
+ def initialize(db, opts={})
6
6
  super
7
7
  @max_connection_age = opts[:max_connection_age] || 1800 # 30 mins
8
8
  @last_uses = {}
@@ -14,7 +14,7 @@ class Sequel::FreshThreadedConnectionPool < Sequel::ThreadedConnectionPool
14
14
  last_use = @last_uses[conn.object_id]
15
15
  connection_age = last_use ? Time.now.to_i - last_use : 0
16
16
  break if connection_age <= @max_connection_age
17
- @disconnection_proc.call(conn) if @disconnection_proc
17
+ db.disconnect_connection(conn) if conn
18
18
  @allocated.delete(thread)
19
19
  @last_uses.delete(conn.object_id)
20
20
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_fresh_connections
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Matthew Sadler
@@ -13,17 +14,19 @@ dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: sequel
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ">="
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
- version: '0'
21
+ version: 3.41.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ">="
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: 3.41.0
27
30
  description: A Sequel extension to remove stale, potentially timed out, connections
28
31
  from the connection pool.
29
32
  email: mat@sourcetagsandcodes.com
@@ -32,37 +35,38 @@ extensions: []
32
35
  extra_rdoc_files:
33
36
  - README.rdoc
34
37
  files:
35
- - README.rdoc
36
38
  - lib/sequel/connection_pool/fresh_sharded_single.rb
37
39
  - lib/sequel/connection_pool/fresh_sharded_threaded.rb
38
40
  - lib/sequel/connection_pool/fresh_single.rb
39
41
  - lib/sequel/connection_pool/fresh_threaded.rb
40
42
  - lib/sequel/extensions/fresh_connections.rb
43
+ - README.rdoc
41
44
  homepage: https://github.com/globaldev/sequel_fresh_connections
42
45
  licenses: []
43
- metadata: {}
44
46
  post_install_message:
45
47
  rdoc_options:
46
- - "--main"
48
+ - --main
47
49
  - README.rdoc
48
- - "--charset"
50
+ - --charset
49
51
  - utf-8
50
52
  require_paths:
51
53
  - lib
52
54
  required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
53
56
  requirements:
54
- - - ">="
57
+ - - ! '>='
55
58
  - !ruby/object:Gem::Version
56
59
  version: '0'
57
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
58
62
  requirements:
59
- - - ">="
63
+ - - ! '>='
60
64
  - !ruby/object:Gem::Version
61
65
  version: '0'
62
66
  requirements: []
63
67
  rubyforge_project:
64
- rubygems_version: 2.4.2
68
+ rubygems_version: 1.8.23.2
65
69
  signing_key:
66
- specification_version: 4
70
+ specification_version: 3
67
71
  summary: Keep your Sequel DB connections fresh
68
72
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 34f62fc00a104fd9bee3bdfa6a92a18fa35d6575
4
- data.tar.gz: 5f6d050a58af9521d7523c6622730869be9d9bfb
5
- SHA512:
6
- metadata.gz: c3d3d094a84e1ed7cc170e27689f929e25928761aaa969b984c69527360778acd92c0e21e8e6be48933fa1f9135fb54c674394f903f5ca6f3efd976d28f56276
7
- data.tar.gz: 3c40bb67b88eec107f479313b8f6192ccfd5a27895112c1ca3853f1ee33bceeb1630362565d020dd1645f158c4a2e442d6de634ccbdec42dac36fc0a6e0ba46b