activerecord-postgres_pub_sub 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +4 -32
- data/CHANGELOG.md +8 -0
- data/README.md +9 -2
- data/activerecord-postgres_pub_sub.gemspec +8 -14
- data/gemfiles/{rails_6.1_pg_1.1.gemfile → activerecord_6.1.gemfile} +0 -1
- data/gemfiles/{rails_7.0_pg_1.1.gemfile → activerecord_7.0.gemfile} +0 -1
- data/gemfiles/{rails_5.2_pg_1.1.gemfile → activerecord_7.1.gemfile} +1 -2
- data/lib/activerecord/postgres_pub_sub/listener.rb +21 -7
- data/lib/activerecord/postgres_pub_sub/version.rb +1 -1
- metadata +19 -41
- data/gemfiles/rails_5.1.gemfile +0 -8
- data/gemfiles/rails_5.2_pg_0.18.gemfile +0 -8
- data/gemfiles/rails_5.2_pg_1.2.gemfile +0 -8
- data/gemfiles/rails_6.0_pg_0.18.gemfile +0 -8
- data/gemfiles/rails_6.0_pg_1.1.gemfile +0 -8
- data/gemfiles/rails_6.0_pg_1.2.gemfile +0 -8
- data/gemfiles/rails_6.1_pg_1.2.gemfile +0 -8
- data/gemfiles/rails_7.0_pg_1.2.gemfile +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a86f260c16eb56f145eec2011339d8f22115c990fe26d39f4be505fa9d687ad
|
4
|
+
data.tar.gz: 1053e77f1bb10c2ff5a5b0d48a7bd5c13855ec39bba841971880862f96b52e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f4ca541c2f9e2016314534874e207e94a3b1c707d903c5c65cff84acc0e90cf049c37b6636c7acd78b276f12db2435ac34fd9942c026ec189d7c948f5887e9a
|
7
|
+
data.tar.gz: f7170043ceb5a1b1ad23374a51137e4d307a0ff8771cdb0b3bbcab40ff0dab29fec3bd4f45367ff1b6505e00424eec8daeefa984f21c51ecac0731624464abdd
|
data/Appraisals
CHANGED
@@ -1,41 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
appraise "
|
4
|
-
gem "activerecord", "5.2.1"
|
5
|
-
gem "pg", "1.1.4"
|
6
|
-
end
|
7
|
-
|
8
|
-
appraise "rails-5.2_pg-1.2" do
|
9
|
-
gem "activerecord", "5.2.1"
|
10
|
-
gem "pg", "1.2.0"
|
11
|
-
end
|
12
|
-
|
13
|
-
appraise "rails-6.0_pg-1.1" do
|
14
|
-
gem "activerecord", ">= 6.0.0", "< 6.1"
|
15
|
-
gem "pg", "1.1.4"
|
16
|
-
end
|
17
|
-
|
18
|
-
appraise "rails-6.0_pg-1.2" do
|
19
|
-
gem "activerecord", ">= 6.0.0", "< 6.1"
|
20
|
-
gem "pg", "1.2.0"
|
21
|
-
end
|
22
|
-
|
23
|
-
appraise "rails-6.1_pg-1.1" do
|
24
|
-
gem "activerecord", ">= 6.1.0", "< 6.2"
|
25
|
-
gem "pg", "1.1.4"
|
26
|
-
end
|
27
|
-
|
28
|
-
appraise "rails-6.1_pg-1.2" do
|
3
|
+
appraise "activerecord_6.1" do
|
29
4
|
gem "activerecord", ">= 6.1.0", "< 6.2"
|
30
|
-
gem "pg", "1.2.0"
|
31
5
|
end
|
32
6
|
|
33
|
-
appraise "
|
7
|
+
appraise "activerecord_7.0" do
|
34
8
|
gem "activerecord", ">= 7.0.0", "< 7.1"
|
35
|
-
gem "pg", "1.1.4"
|
36
9
|
end
|
37
10
|
|
38
|
-
appraise "
|
39
|
-
gem "activerecord", ">= 7.
|
40
|
-
gem "pg", "1.2.0"
|
11
|
+
appraise "activerecord_7.1" do
|
12
|
+
gem "activerecord", ">= 7.1.0", "< 7.2"
|
41
13
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# activerecord-postgres_pub_sub
|
2
2
|
|
3
|
+
## v3.0.0
|
4
|
+
- Add support for multiple databases by allowing injection of the base Active Record class.
|
5
|
+
- BREAKING: Drop support for ActiveRecord 5.2, 6.0
|
6
|
+
- BREAKING: Drop support for ruby < 3.0
|
7
|
+
|
8
|
+
## v2.3.0
|
9
|
+
- Add support for Rails 7.1
|
10
|
+
|
3
11
|
## v2.2.0
|
4
12
|
- Add support for listening to multiple channels.
|
5
13
|
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# activerecord-postgres_pub_sub
|
2
2
|
|
3
|
-
[![CircleCI](https://circleci.com/gh/ezcater/activerecord-postgres_pub_sub.svg?style=svg)](https://circleci.com/gh/ezcater/activerecord-postgres_pub_sub)
|
4
|
-
|
5
3
|
This gem contains support for PostgreSQL LISTEN and NOTIFY functionality:
|
6
4
|
[doc](https://www.postgresql.org/docs/9.6/static/libpq-notify.html).
|
7
5
|
|
@@ -43,6 +41,8 @@ When creating a listener, the following configuration is supported:
|
|
43
41
|
the listener ignores the payload and coalesces multiple notifications into a
|
44
42
|
single call. When this option is `false`, the `on_notify` block is called with
|
45
43
|
the payload for each notification. (Default `true`).
|
44
|
+
* **base_class**: An Active Record class should you need to use a different base
|
45
|
+
class (e.g. for multiple database support). (Default `ActiveRecord::Base`).
|
46
46
|
* **exclusive_lock**: Acquire a lock using
|
47
47
|
[with_advisory_lock](https://github.com/ClosureTree/with_advisory_lock) prior to listening.
|
48
48
|
This option ensures that a process as a singleton listener. (Default `true`).
|
@@ -79,6 +79,13 @@ rails generate active_record:postgres_pub_sub:notify_on_insert --model_name Name
|
|
79
79
|
In this example, notification events would be generated for the channel named `"name_space_entity"` based
|
80
80
|
on inserts to the `name_space_entities` table.
|
81
81
|
|
82
|
+
## Supported dependencies
|
83
|
+
|
84
|
+
This gem will not support versions of ruby and activerecord which no
|
85
|
+
longer receive security updates. It will support the latest major
|
86
|
+
version of the pg gem and it will be tested against the latest minor /
|
87
|
+
patch version of that gem.
|
88
|
+
|
82
89
|
## Development
|
83
90
|
|
84
91
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
@@ -21,39 +21,33 @@ Gem::Specification.new do |spec|
|
|
21
21
|
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
22
|
end
|
23
23
|
|
24
|
-
excluded_files = %w(.
|
25
|
-
.github/PULL_REQUEST_TEMPLATE.md
|
26
|
-
.gitignore
|
24
|
+
excluded_files = %w(.gitignore
|
27
25
|
.rspec
|
28
26
|
.rubocop.yml
|
29
27
|
.ruby-gemset
|
30
|
-
.
|
31
|
-
.travis.yml
|
32
|
-
bin/console
|
33
|
-
bin/setup
|
28
|
+
.tool-versions
|
34
29
|
Rakefile)
|
35
30
|
|
36
31
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
37
|
-
f.match(/^(test|spec|features)\//)
|
32
|
+
f.match(/^(bin|test|spec|features|.github)\//)
|
38
33
|
end - excluded_files
|
39
34
|
spec.bindir = "bin"
|
40
35
|
spec.executables = []
|
41
36
|
spec.require_paths = ["lib"]
|
42
|
-
spec.required_ruby_version = ">=
|
37
|
+
spec.required_ruby_version = ">= 3.0.0"
|
43
38
|
|
44
|
-
spec.add_runtime_dependency "activerecord", ">
|
39
|
+
spec.add_runtime_dependency "activerecord", "> 6.0", "< 7.2"
|
45
40
|
spec.add_runtime_dependency "pg", "~> 1.1"
|
46
41
|
spec.add_runtime_dependency "private_attr"
|
47
42
|
spec.add_runtime_dependency "with_advisory_lock"
|
48
43
|
|
49
44
|
spec.add_development_dependency "appraisal"
|
50
|
-
spec.add_development_dependency "bundler", "
|
45
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
51
46
|
spec.add_development_dependency "database_cleaner"
|
52
47
|
spec.add_development_dependency "ezcater_matchers"
|
53
|
-
spec.add_development_dependency "ezcater_rubocop", "~>
|
48
|
+
spec.add_development_dependency "ezcater_rubocop", "~> 6.1.0"
|
54
49
|
spec.add_development_dependency "overcommit"
|
55
|
-
spec.add_development_dependency "rake", "~>
|
50
|
+
spec.add_development_dependency "rake", "~> 13.1"
|
56
51
|
spec.add_development_dependency "rspec", "~> 3.4"
|
57
|
-
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
|
58
52
|
spec.add_development_dependency "simplecov"
|
59
53
|
end
|
@@ -9,22 +9,36 @@ module ActiveRecord
|
|
9
9
|
extend PrivateAttr
|
10
10
|
|
11
11
|
private_attr_reader :on_notify_blk, :on_start_blk, :on_timeout_blk,
|
12
|
-
:channels, :listen_timeout, :exclusive_lock, :notify_only
|
13
|
-
|
14
|
-
def self.listen(
|
12
|
+
:channels, :listen_timeout, :exclusive_lock, :notify_only, :base_class
|
13
|
+
|
14
|
+
def self.listen(
|
15
|
+
*channels,
|
16
|
+
listen_timeout: nil,
|
17
|
+
exclusive_lock: true,
|
18
|
+
notify_only: true,
|
19
|
+
base_class: ActiveRecord::Base
|
20
|
+
)
|
15
21
|
listener = new(*channels,
|
16
22
|
listen_timeout: listen_timeout,
|
17
23
|
exclusive_lock: exclusive_lock,
|
18
|
-
notify_only: notify_only
|
24
|
+
notify_only: notify_only,
|
25
|
+
base_class: base_class)
|
19
26
|
yield(listener) if block_given?
|
20
27
|
listener.listen
|
21
28
|
end
|
22
29
|
|
23
|
-
def initialize(
|
30
|
+
def initialize(
|
31
|
+
*channels,
|
32
|
+
listen_timeout: nil,
|
33
|
+
exclusive_lock: true,
|
34
|
+
notify_only: true,
|
35
|
+
base_class: ActiveRecord::Base
|
36
|
+
)
|
24
37
|
@channels = channels
|
25
38
|
@listen_timeout = listen_timeout
|
26
39
|
@exclusive_lock = exclusive_lock
|
27
40
|
@notify_only = notify_only
|
41
|
+
@base_class = base_class
|
28
42
|
end
|
29
43
|
|
30
44
|
def on_notify(&blk)
|
@@ -54,7 +68,7 @@ module ActiveRecord
|
|
54
68
|
private
|
55
69
|
|
56
70
|
def with_connection
|
57
|
-
|
71
|
+
base_class.connection_pool.with_connection do |connection|
|
58
72
|
with_optional_lock do
|
59
73
|
channels.each do |channel|
|
60
74
|
connection.execute("LISTEN #{channel};")
|
@@ -73,7 +87,7 @@ module ActiveRecord
|
|
73
87
|
|
74
88
|
def with_optional_lock(&block)
|
75
89
|
if exclusive_lock
|
76
|
-
|
90
|
+
base_class.with_advisory_lock(lock_name, &block)
|
77
91
|
else
|
78
92
|
yield
|
79
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-postgres_pub_sub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6.0'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7.
|
22
|
+
version: '7.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '6.0'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7.
|
32
|
+
version: '7.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: pg
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,16 +90,16 @@ dependencies:
|
|
90
90
|
name: bundler
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- - "
|
93
|
+
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: '2.2'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- - "
|
100
|
+
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: '2.2'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: database_cleaner
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,14 +134,14 @@ dependencies:
|
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
137
|
+
version: 6.1.0
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
144
|
+
version: 6.1.0
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: overcommit
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,14 +162,14 @@ dependencies:
|
|
162
162
|
requirements:
|
163
163
|
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
165
|
+
version: '13.1'
|
166
166
|
type: :development
|
167
167
|
prerelease: false
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: '
|
172
|
+
version: '13.1'
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: rspec
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,20 +184,6 @@ dependencies:
|
|
184
184
|
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '3.4'
|
187
|
-
- !ruby/object:Gem::Dependency
|
188
|
-
name: rspec_junit_formatter
|
189
|
-
requirement: !ruby/object:Gem::Requirement
|
190
|
-
requirements:
|
191
|
-
- - '='
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: 0.2.2
|
194
|
-
type: :development
|
195
|
-
prerelease: false
|
196
|
-
version_requirements: !ruby/object:Gem::Requirement
|
197
|
-
requirements:
|
198
|
-
- - '='
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: 0.2.2
|
201
187
|
- !ruby/object:Gem::Dependency
|
202
188
|
name: simplecov
|
203
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,17 +211,9 @@ files:
|
|
225
211
|
- LICENSE.txt
|
226
212
|
- README.md
|
227
213
|
- activerecord-postgres_pub_sub.gemspec
|
228
|
-
- gemfiles/
|
229
|
-
- gemfiles/
|
230
|
-
- gemfiles/
|
231
|
-
- gemfiles/rails_5.2_pg_1.2.gemfile
|
232
|
-
- gemfiles/rails_6.0_pg_0.18.gemfile
|
233
|
-
- gemfiles/rails_6.0_pg_1.1.gemfile
|
234
|
-
- gemfiles/rails_6.0_pg_1.2.gemfile
|
235
|
-
- gemfiles/rails_6.1_pg_1.1.gemfile
|
236
|
-
- gemfiles/rails_6.1_pg_1.2.gemfile
|
237
|
-
- gemfiles/rails_7.0_pg_1.1.gemfile
|
238
|
-
- gemfiles/rails_7.0_pg_1.2.gemfile
|
214
|
+
- gemfiles/activerecord_6.1.gemfile
|
215
|
+
- gemfiles/activerecord_7.0.gemfile
|
216
|
+
- gemfiles/activerecord_7.1.gemfile
|
239
217
|
- lib/activerecord-postgres_pub_sub.rb
|
240
218
|
- lib/activerecord/postgres_pub_sub/listener.rb
|
241
219
|
- lib/activerecord/postgres_pub_sub/version.rb
|
@@ -254,14 +232,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
254
232
|
requirements:
|
255
233
|
- - ">="
|
256
234
|
- !ruby/object:Gem::Version
|
257
|
-
version:
|
235
|
+
version: 3.0.0
|
258
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
237
|
requirements:
|
260
238
|
- - ">="
|
261
239
|
- !ruby/object:Gem::Version
|
262
240
|
version: '0'
|
263
241
|
requirements: []
|
264
|
-
rubygems_version: 3.
|
242
|
+
rubygems_version: 3.2.33
|
265
243
|
signing_key:
|
266
244
|
specification_version: 4
|
267
245
|
summary: Support for Postgres Notify/Listen
|
data/gemfiles/rails_5.1.gemfile
DELETED