pgtk 0.20.1 → 0.21.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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/pgtk/impatient.rb +7 -1
- data/lib/pgtk/pool.rb +3 -3
- data/lib/pgtk/retry.rb +2 -1
- data/lib/pgtk/spy.rb +7 -1
- data/lib/pgtk/stash.rb +2 -9
- data/lib/pgtk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e46e57835cc795fd4c73ef4016911c17cf3e088ddadda330f72a25efe56aa8c5
|
|
4
|
+
data.tar.gz: e921ed037a9b9ea1291513959bc73809fb615dac2e1f35a5f74d272514596396
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdffbbdd4ee6e868ec6b61a7cc9d674f4ba17db9cf968b49fa6dbc3e6a92f9edc25d31f439fa30bbb3aab6a6d7ceac12a4b63e752bde38659f54dafa0ea2d67f
|
|
7
|
+
data.tar.gz: af7a104cffffd53bbdcb6a4a25666115fae8f0b5f312971a1244ce28030acdca11d673d244fb4303fcfe9594928e107ea69fc9070ebecc2e23f6d7533dbb4376
|
data/README.md
CHANGED
|
@@ -116,7 +116,7 @@ From inside your app you may find this class useful:
|
|
|
116
116
|
```ruby
|
|
117
117
|
require 'pgtk/pool'
|
|
118
118
|
pgsql = Pgtk::Pool.new(Pgtk::Wire::Yaml.new('config.yml'))
|
|
119
|
-
pgsql.start(5) # Start it with five simultaneous connections
|
|
119
|
+
pgsql.start!(5) # Start it with five simultaneous connections
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
You can also let it pick the connection parameters from the environment
|
|
@@ -155,7 +155,8 @@ module Minitest
|
|
|
155
155
|
def test_pgsql
|
|
156
156
|
@@test_pgsql ||= Pgtk::Pool.new(
|
|
157
157
|
Pgtk::Wire::Yaml.new('target/pgsql-config.yml')
|
|
158
|
-
)
|
|
158
|
+
)
|
|
159
|
+
@@test_pgsql.start!
|
|
159
160
|
end
|
|
160
161
|
end
|
|
161
162
|
end
|
data/lib/pgtk/impatient.rb
CHANGED
|
@@ -19,7 +19,8 @@ require_relative '../pgtk'
|
|
|
19
19
|
# Basic usage:
|
|
20
20
|
#
|
|
21
21
|
# # Create and configure a regular pool
|
|
22
|
-
# pool = Pgtk::Pool.new(wire)
|
|
22
|
+
# pool = Pgtk::Pool.new(wire)
|
|
23
|
+
# pool.start!(4)
|
|
23
24
|
#
|
|
24
25
|
# # Wrap the pool in an impatient decorator with a 2-second timeout
|
|
25
26
|
# impatient = Pgtk::Impatient.new(pool, 2)
|
|
@@ -67,6 +68,11 @@ class Pgtk::Impatient
|
|
|
67
68
|
@off = off
|
|
68
69
|
end
|
|
69
70
|
|
|
71
|
+
# Start a new connection pool with the given arguments.
|
|
72
|
+
def start!(*)
|
|
73
|
+
@pool.start!
|
|
74
|
+
end
|
|
75
|
+
|
|
70
76
|
# Get the version of PostgreSQL server.
|
|
71
77
|
#
|
|
72
78
|
# @return [String] Version of PostgreSQL server
|
data/lib/pgtk/pool.rb
CHANGED
|
@@ -29,7 +29,8 @@ require_relative 'wire'
|
|
|
29
29
|
# )
|
|
30
30
|
#
|
|
31
31
|
# # Create and start a connection pool with 4 connections
|
|
32
|
-
# pool = Pgtk::Pool.new(wire)
|
|
32
|
+
# pool = Pgtk::Pool.new(wire)
|
|
33
|
+
# pool.start!(4)
|
|
33
34
|
#
|
|
34
35
|
# # Execute a simple query
|
|
35
36
|
# pool.exec('SELECT * FROM users')
|
|
@@ -85,12 +86,11 @@ class Pgtk::Pool
|
|
|
85
86
|
# allows only one connection open.
|
|
86
87
|
#
|
|
87
88
|
# @param [Integer] max Total amount of PostgreSQL connections in the pool
|
|
88
|
-
def start(max = 8)
|
|
89
|
+
def start!(max = 8)
|
|
89
90
|
max.times do
|
|
90
91
|
@pool << @wire.connection
|
|
91
92
|
end
|
|
92
93
|
@log.debug("PostgreSQL pool started with #{max} connections")
|
|
93
|
-
self
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
# Make a query and return the result as an array of hashes. For example,
|
data/lib/pgtk/retry.rb
CHANGED
|
@@ -16,7 +16,8 @@ require_relative '../pgtk'
|
|
|
16
16
|
# Basic usage:
|
|
17
17
|
#
|
|
18
18
|
# # Create and configure a regular pool
|
|
19
|
-
# pool = Pgtk::Pool.new(wire)
|
|
19
|
+
# pool = Pgtk::Pool.new(wire)
|
|
20
|
+
# pool.start!(4)
|
|
20
21
|
#
|
|
21
22
|
# # Wrap the pool in a retry decorator with 3 attempts
|
|
22
23
|
# retry_pool = Pgtk::Retry.new(pool, attempts: 3)
|
data/lib/pgtk/spy.rb
CHANGED
|
@@ -19,7 +19,8 @@ require_relative 'wire'
|
|
|
19
19
|
# Basic usage:
|
|
20
20
|
#
|
|
21
21
|
# # Create and configure a regular pool
|
|
22
|
-
# pool = Pgtk::Pool.new(wire)
|
|
22
|
+
# pool = Pgtk::Pool.new(wire)
|
|
23
|
+
# pool.start!(4)
|
|
23
24
|
#
|
|
24
25
|
# # Wrap the pool in a spy that tracks all executed queries
|
|
25
26
|
# queries = []
|
|
@@ -55,6 +56,11 @@ class Pgtk::Spy
|
|
|
55
56
|
@block = block
|
|
56
57
|
end
|
|
57
58
|
|
|
59
|
+
# Start a new connection pool with the given arguments.
|
|
60
|
+
def start!(*)
|
|
61
|
+
@pool.start!
|
|
62
|
+
end
|
|
63
|
+
|
|
58
64
|
# Get the version of PostgreSQL server.
|
|
59
65
|
#
|
|
60
66
|
# @return [String] Version of PostgreSQL server
|
data/lib/pgtk/stash.rb
CHANGED
|
@@ -163,16 +163,9 @@ class Pgtk::Stash
|
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
# Start a new connection pool with the given arguments.
|
|
166
|
-
|
|
167
|
-
def start(*)
|
|
166
|
+
def start!(*)
|
|
168
167
|
launch!
|
|
169
|
-
|
|
170
|
-
@pool.start(*), @stash,
|
|
171
|
-
refill_interval: @refill_interval,
|
|
172
|
-
top: @top,
|
|
173
|
-
threads: @threads,
|
|
174
|
-
loog: @loog
|
|
175
|
-
)
|
|
168
|
+
@pool.start!(*)
|
|
176
169
|
end
|
|
177
170
|
|
|
178
171
|
private
|
data/lib/pgtk/version.rb
CHANGED