midget_jobs 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/midget_jobs/version.rb +1 -1
- data/lib/models/concerns/postgres_notifications_listener.rb +12 -9
- 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: b3e3afb7822a9f252d8442f20d7bf89f80e23cb0d782cff7b53427803c67ff5c
|
4
|
+
data.tar.gz: bf1d546693adaa2c2349b220d4677bad7c7def45ad2b2fda835e0f83247dd036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdadf27c542f6fbef5d84067b54acbb871d95bfc4f319e480705ef73687553918cc2c008c7b5feef565521fdb91b6dce7f442081d076382f19ceb167fae61dd2
|
7
|
+
data.tar.gz: dd99f425b0939821dc2cd00d9cce0fd8fce80b0c064cb007732b8cb4e2e583e1bab3d8372a48e0b55e7118ccb2c8a381eb00e2afc13c675e6e2bf5716ad9bf57
|
data/lib/midget_jobs/version.rb
CHANGED
@@ -6,6 +6,7 @@ module PostgresNotificationsListener
|
|
6
6
|
Thread.new do
|
7
7
|
Rails.logger.info "#{name} listening_job running on #{name.pluralize.underscore}_notices"
|
8
8
|
connection.execute "LISTEN #{name.pluralize.underscore}_notices"
|
9
|
+
exception_counter ||= 0
|
9
10
|
loop do
|
10
11
|
Rails.logger.info "#{name} listening_job wait_for_notify"
|
11
12
|
connection.raw_connection.wait_for_notify do |event, pid, payload|
|
@@ -13,17 +14,19 @@ module PostgresNotificationsListener
|
|
13
14
|
Rails.logger.info "postgres #{event.inspect}, pid: #{pid.inspect}, data: #{data.inspect}"
|
14
15
|
process_notification(data)
|
15
16
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
exception_counter = 0
|
18
|
+
rescue PG::ConnectionBad => e
|
19
|
+
exception_counter += 1
|
20
|
+
Rails.logger.error "#{name} listening_job wait_for_notify lost connection #{e.inspect} retry #{exception_counter}th time!"
|
21
|
+
Rails.logger.error "Reestablish AR connection..."
|
22
|
+
ActiveRecord::Base.connection.verify!
|
22
23
|
sleep 0.1
|
23
|
-
retry
|
24
|
+
(exception_counter < 3) ? retry : raise(e)
|
24
25
|
rescue StandardError => e
|
25
|
-
|
26
|
-
retry
|
26
|
+
exception_counter += 1
|
27
|
+
Rails.logger.error "#{name} listening_job wait_for_notify exception #{e.inspect} retry #{exception_counter}th time!"
|
28
|
+
sleep 0.1
|
29
|
+
(exception_counter < 3) ? retry : raise(e)
|
27
30
|
end
|
28
31
|
end.abort_on_exception = true
|
29
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midget_jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- josefchmel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|