midget_jobs 0.2.2 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f31ce7256430433d6371404650a9a13eed0e22bcabf74dae66fad28ede2a037c
4
- data.tar.gz: 70dd350c6c5ab4c64048e7dd120f9f7a8ab0e5586808a101df1dd4a04b27a859
3
+ metadata.gz: b3e3afb7822a9f252d8442f20d7bf89f80e23cb0d782cff7b53427803c67ff5c
4
+ data.tar.gz: bf1d546693adaa2c2349b220d4677bad7c7def45ad2b2fda835e0f83247dd036
5
5
  SHA512:
6
- metadata.gz: 3eadc0b0adf4aa7eb624e1a0544ce985d1740e912793363b54bced5cc0cab9ba741e4a71bf8b126fccd9999905d94cfb48f49f1299f7c4f19c9fd92698c33309
7
- data.tar.gz: 603cb4139df7662a141acb2fdd1966a2875af20e4ed4bce843b1ed1422731ac10455bee3af9a51775cb2fa5f8847ea2bfb65db5d25890256fc0e66ec81d5c0ee
6
+ metadata.gz: cdadf27c542f6fbef5d84067b54acbb871d95bfc4f319e480705ef73687553918cc2c008c7b5feef565521fdb91b6dce7f442081d076382f19ceb167fae61dd2
7
+ data.tar.gz: dd99f425b0939821dc2cd00d9cce0fd8fce80b0c064cb007732b8cb4e2e583e1bab3d8372a48e0b55e7118ccb2c8a381eb00e2afc13c675e6e2bf5716ad9bf57
@@ -1,3 +1,3 @@
1
1
  module MidgetJobs
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -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
- rescue ActiveRecord::StatementInvalid => e
17
- Rails.logger.error "Ex #{name} listening_job wait_for_notify #{e}-retrying!"
18
- if e.to_s.include?('PG::ConnectionBad')
19
- Rails.logger.error "Reestablish AR connection..."
20
- ActiveRecord::Base.connection.verify!
21
- end
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
- Rails.logger.error "Ex #{name} listening_job wait_for_notify #{e}-retrying!"
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.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-04-24 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler