pg_versions 3.0 → 3.2
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/lib/pg_versions/pg_versions.rb +12 -12
- data/lib/pg_versions/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ea60eca0dd6405306d3e80e7c01772e8644fe8daecd09a07f9439163b1d6f53
|
4
|
+
data.tar.gz: 8d6ccbee35978c06f6c39ff7a664dc5492fabf73aac900260810f46945662051
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a32c0f6ed7d13ccf64355320d9d2a3ea5c5a21a20e9f8ec82d464334aa993bc3bff406c7f8c6ecaa235f9d265d49251678d4006e2b6f6cd183c823ff850c5d3
|
7
|
+
data.tar.gz: 2367a601daea6ecffe34e6dd6b752c7886c42029d05cfc477e9174a83ca91de475244c7eaed2ff6e7fdb85c461e51dc0316863a96f37ce5eade36b0d13b00fc0
|
@@ -38,7 +38,7 @@ module PgVersions
|
|
38
38
|
class ConnectionClosed < StandardError; end
|
39
39
|
|
40
40
|
def self.timestamp_to_integers(input)
|
41
|
-
"to_char(%s, 'YYYYMMDD')::integer || ',' || to_char(%s, 'HH24MISS')::integer || ',' || to_char(%s, 'US')::integer"%[input, input, input]
|
41
|
+
"to_char(%s AT TIME ZONE 'UTC', 'YYYYMMDD')::integer || ',' || to_char(%s AT TIME ZONE 'UTC', 'HH24MISS')::integer || ',' || to_char(%s AT TIME ZONE 'UTC', 'US')::integer"%[input, input, input]
|
42
42
|
end
|
43
43
|
|
44
44
|
|
@@ -111,7 +111,7 @@ module PgVersions
|
|
111
111
|
|
112
112
|
|
113
113
|
def self.bump_sql(*channels)
|
114
|
-
channels = [channels].flatten
|
114
|
+
channels = [channels].flatten
|
115
115
|
return "" if channels.size == 0
|
116
116
|
encoder = PG::TextEncoder::QuotedLiteral.new(elements_type: PG::TextEncoder::String.new)
|
117
117
|
quoted_channels = channels.map.with_index { |channel, i| "(#{i},#{encoder.encode(channel)})" }.join(", ")
|
@@ -143,7 +143,7 @@ module PgVersions
|
|
143
143
|
|
144
144
|
#TODO: ensure this is called only once per transaction, or that all bumps occur in the same order in all transactions, to avoid deadlocks
|
145
145
|
def self.bump(connection, *channels)
|
146
|
-
channels = [channels].flatten.sort
|
146
|
+
channels = [channels].flatten.sort.uniq
|
147
147
|
PgVersions.with_connection(connection, false) { |pg_connection|
|
148
148
|
sql = self.bump_sql(*channels)
|
149
149
|
return {} if sql == ""
|
@@ -153,13 +153,13 @@ module PgVersions
|
|
153
153
|
}
|
154
154
|
end
|
155
155
|
|
156
|
-
|
156
|
+
|
157
157
|
#TODO: bump in the same query instead of calling bump
|
158
158
|
#TODO: do we really need to bump though?
|
159
159
|
#TODO: and then, implement read_sql
|
160
160
|
def self.read(connection, *channels)
|
161
161
|
PgVersions.with_connection(connection, false) { |pg_connection|
|
162
|
-
channels = [channels].flatten.sort
|
162
|
+
channels = [channels].flatten.sort.uniq
|
163
163
|
return {} if channels.size == 0
|
164
164
|
versions = {}
|
165
165
|
quoted_channels = channels.map.with_index { |channel, i| "(#{i},'#{pg_connection.escape_string(channel)}')" }.join(", ")
|
@@ -196,7 +196,7 @@ module PgVersions
|
|
196
196
|
|
197
197
|
|
198
198
|
class ConnectionInner
|
199
|
-
|
199
|
+
|
200
200
|
def initialize()
|
201
201
|
@mutex = Mutex.new
|
202
202
|
@command_notify_w = nil
|
@@ -222,7 +222,7 @@ module PgVersions
|
|
222
222
|
end
|
223
223
|
}
|
224
224
|
begin
|
225
|
-
command_notify_r, @command_notify_w = IO.pipe
|
225
|
+
command_notify_r, @command_notify_w = IO.pipe
|
226
226
|
Thread.handle_interrupt(Object => :immediate) {
|
227
227
|
yield command_notify_r
|
228
228
|
}
|
@@ -247,7 +247,7 @@ module PgVersions
|
|
247
247
|
end
|
248
248
|
end
|
249
249
|
|
250
|
-
|
250
|
+
|
251
251
|
def wake_processor
|
252
252
|
@command_notify_w&.write('!')
|
253
253
|
@command_notify_w&.flush
|
@@ -358,7 +358,7 @@ module PgVersions
|
|
358
358
|
when :idle
|
359
359
|
@state = :closed
|
360
360
|
return
|
361
|
-
when :processing
|
361
|
+
when :processing
|
362
362
|
@state = :closing
|
363
363
|
@closers << result
|
364
364
|
wake_processor
|
@@ -387,7 +387,7 @@ module PgVersions
|
|
387
387
|
|
388
388
|
retry_on_exceptions = [ ::PG::ConnectionBad, ::PG::UnableToSend ]
|
389
389
|
retry_delay = 0
|
390
|
-
|
390
|
+
|
391
391
|
@inner.process do |notification_r|
|
392
392
|
raise if not notification_r
|
393
393
|
PgVersions.with_connection(connection_param, true) do |pg_connection|
|
@@ -402,10 +402,10 @@ module PgVersions
|
|
402
402
|
|
403
403
|
loop {
|
404
404
|
channels_to_listen_to = @inner.get_channels
|
405
|
-
(listening_to_channels - channels_to_listen_to).each { |removed_channel|
|
405
|
+
(listening_to_channels - channels_to_listen_to).each { |removed_channel|
|
406
406
|
pg_connection.exec("UNLISTEN #{::PG::Connection.quote_ident(removed_channel)}")
|
407
407
|
}
|
408
|
-
(channels_to_listen_to - listening_to_channels).each { |added_channel|
|
408
|
+
(channels_to_listen_to - listening_to_channels).each { |added_channel|
|
409
409
|
pg_connection.exec("LISTEN #{::PG::Connection.quote_ident(added_channel)}")
|
410
410
|
}
|
411
411
|
listening_to_channels = channels_to_listen_to
|
data/lib/pg_versions/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_versions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '3.
|
4
|
+
version: '3.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yunta
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rspec
|
@@ -85,7 +84,6 @@ homepage: https://gitlab.com/yunta/pg-versions
|
|
85
84
|
licenses:
|
86
85
|
- MIT
|
87
86
|
metadata: {}
|
88
|
-
post_install_message:
|
89
87
|
rdoc_options: []
|
90
88
|
require_paths:
|
91
89
|
- lib
|
@@ -100,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
98
|
- !ruby/object:Gem::Version
|
101
99
|
version: '0'
|
102
100
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
104
|
-
signing_key:
|
101
|
+
rubygems_version: 3.6.9
|
105
102
|
specification_version: 4
|
106
103
|
summary: Persistent timestamped postgres notification library
|
107
104
|
test_files: []
|