pgtk 0.7.0 → 0.7.1
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 +8 -1
- data/lib/pgtk/pool.rb +4 -3
- data/lib/pgtk/version.rb +1 -1
- data/lib/pgtk/wire.rb +1 -1
- data/test/test_pool.rb +17 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13fb64166a42e15fcc78444b4ea01a3b8fcd9039272d5c7fa98a8dc72b879c57
|
4
|
+
data.tar.gz: 80cd807f7fa20fa256ffba82e033673a58dc9cf453bf4cb5387a8d591cd31206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ea2debe02d73ad8ac645b40e184fac2f03f575d05dc3bd099a090233d1a380b65f158f909d77bd51281a32a4b280b7ccf7891f259995c0f3c8e67c10188de88
|
7
|
+
data.tar.gz: d5d4c3a4d664ac09801f3464f2eefeb6d28a257717f0ee63d88f27b7b3bd6b9348de0a9f35e9daabe203c8428830327961a70690d5eeae6515169a6c24cfe6fe
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
[](https://codecov.io/github/yegor256/pgtk?branch=master)
|
16
16
|
[](https://hitsofcode.com/view/github/yegor256/pgtk)
|
17
17
|
|
18
|
-
This small Ruby gem helps you integrate PostgreSQL with your Ruby
|
18
|
+
This small Ruby gem helps you integrate [PostgreSQL](https://www.postgresql.org/) with your Ruby
|
19
19
|
web app, through [Liquibase](https://www.liquibase.org/). It also adds a simple connection pool
|
20
20
|
and query processor, to make SQL manipulation simpler.
|
21
21
|
|
@@ -120,6 +120,13 @@ Should work. Well, it works in [zold-io/wts.zold.io](https://github.com/zold-io/
|
|
120
120
|
and [yegor256/mailanes](https://github.com/yegor256/mailanes). They both are
|
121
121
|
open source, you can see how they use `pgtk`.
|
122
122
|
|
123
|
+
These open source web apps of mine are using pgtk (check their source code
|
124
|
+
to see how it all works):
|
125
|
+
|
126
|
+
* [wts.zold.io](https://github.com/zold-io/wts.zold.io)
|
127
|
+
* [mailanes](https://github.com/yegor256/mailanes)
|
128
|
+
* [0rsk](https://github.com/yegor256/0rsk)
|
129
|
+
|
123
130
|
## How to contribute
|
124
131
|
|
125
132
|
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
data/lib/pgtk/pool.rb
CHANGED
@@ -148,7 +148,7 @@ class Pgtk::Pool
|
|
148
148
|
rows
|
149
149
|
end
|
150
150
|
end
|
151
|
-
@log.debug("#{sql}: #{(start - Time.now).round}ms")
|
151
|
+
@log.debug("#{sql}: #{(start - Time.now).round}ms / #{@conn.object_id}")
|
152
152
|
out
|
153
153
|
end
|
154
154
|
end
|
@@ -159,9 +159,10 @@ class Pgtk::Pool
|
|
159
159
|
conn = @pool.pop
|
160
160
|
begin
|
161
161
|
yield conn
|
162
|
-
rescue
|
162
|
+
rescue StandardError => e
|
163
163
|
conn.close
|
164
|
-
|
164
|
+
conn = @wire.connection
|
165
|
+
raise e
|
165
166
|
ensure
|
166
167
|
@pool << conn
|
167
168
|
end
|
data/lib/pgtk/version.rb
CHANGED
data/lib/pgtk/wire.rb
CHANGED
data/test/test_pool.rb
CHANGED
@@ -22,8 +22,10 @@
|
|
22
22
|
|
23
23
|
require 'minitest/autorun'
|
24
24
|
require 'tmpdir'
|
25
|
+
require 'pg'
|
25
26
|
require 'rake'
|
26
27
|
require 'yaml'
|
28
|
+
require 'loog'
|
27
29
|
require_relative '../lib/pgtk/pgsql_task'
|
28
30
|
require_relative '../lib/pgtk/liquibase_task'
|
29
31
|
require_relative '../lib/pgtk/pool'
|
@@ -67,6 +69,17 @@ class TestPool < Minitest::Test
|
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
72
|
+
def test_reconnects_on_pg_error
|
73
|
+
bootstrap do |pool|
|
74
|
+
assert_raises PG::UndefinedTable do
|
75
|
+
pool.exec('SELECT * FROM thisiserror')
|
76
|
+
end
|
77
|
+
5.times do
|
78
|
+
pool.exec('SELECT * FROM book')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
70
83
|
private
|
71
84
|
|
72
85
|
def bootstrap
|
@@ -87,7 +100,10 @@ class TestPool < Minitest::Test
|
|
87
100
|
t.quiet = true
|
88
101
|
end
|
89
102
|
Rake::Task["liquibase#{id}"].invoke
|
90
|
-
pool = Pgtk::Pool.new(
|
103
|
+
pool = Pgtk::Pool.new(
|
104
|
+
Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')),
|
105
|
+
log: Loog::VERBOSE
|
106
|
+
)
|
91
107
|
pool.start(1)
|
92
108
|
yield pool
|
93
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pgtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|