perfectqueue 0.8.52 → 0.8.53

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12dbac4bd43f2530c655cca57966c3ef526cf80e
4
- data.tar.gz: fc5ca0c0c89dd05e8a3108b2f85da926c63e7429
3
+ metadata.gz: d8e8fc7751663faba5c1ac7de3151649c42a3493
4
+ data.tar.gz: c7f27e4e75b0faa7aceb267ef478089641291269
5
5
  SHA512:
6
- metadata.gz: 22fe10784102843c3de34a55871c6c7d69ce79ca339036eeff97c482a24339a1dce3ca4dea1675100a7c31c9379493dca52b98108683462a1ed79c544706e921
7
- data.tar.gz: 23794ebacf99f34dcaa87d007f1460800f42f5ba75c8ec21e10b17a57f370b1b216cc6559eb44ade47d2860ec144678d822baaea587484f2ad87e89baec327c6
6
+ metadata.gz: c64103797dd50c941a428bc6e265a4f54104773b781447de70c3f3fedbc487efdcdb9858e20b0d48a151d6149e6359cefbe6f94b988e35abd3a35dd0db9e9c11
7
+ data.tar.gz: 8abe49cd58c5b38c8eb3b713c2e9c259a9189993e445520afd2a561db57d52650a6e59305ea7874ead43c03d12d4c476b04d667e41f8faa95203d78110b6857a
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 2019-10-10 version 0.8.53
2
+
3
+ * Extract max_retry_count as config parameter (#66)
4
+
1
5
  == 2019-07-31 version 0.8.52
2
6
 
3
7
  * Add sleep lock retrying with exponential-backoff (#64)
@@ -4,7 +4,6 @@ require_relative 'rdb_compat'
4
4
 
5
5
  module PerfectQueue::Backend
6
6
  class RDBBackend
7
- MAX_RETRY = ::PerfectQueue::Backend::RDBCompatBackend::MAX_RETRY
8
7
  DELETE_OFFSET = ::PerfectQueue::Backend::RDBCompatBackend::DELETE_OFFSET
9
8
  class Token < Struct.new(:key)
10
9
  end
@@ -22,6 +21,7 @@ module PerfectQueue::Backend
22
21
  port: u.port ? u.port.to_i : 3306
23
22
  }
24
23
  @pq_connect_timeout = config.fetch(:pq_connect_timeout, 20)
24
+ @max_retry_count = config.fetch(:max_retry_count, 10)
25
25
  options[:connect_timeout] = config.fetch(:connect_timeout, 3)
26
26
  options[:sslca] = config[:sslca] if config[:sslca]
27
27
  db_name = u.path.split('/')[1]
@@ -34,6 +34,7 @@ module PerfectQueue::Backend
34
34
  end
35
35
 
36
36
  attr_reader :db
37
+ attr_reader :max_retry_count
37
38
 
38
39
  def submit(id, data, time=Process.clock_gettime(Process::CLOCK_REALTIME, :second), resource=nil, max_running=nil)
39
40
  connect {
@@ -63,7 +64,7 @@ module PerfectQueue::Backend
63
64
  begin
64
65
  yield
65
66
  rescue Sequel::DatabaseConnectionError
66
- if (retry_count += 1) < MAX_RETRY && tmax > Process.clock_gettime(Process::CLOCK_REALTIME, :second)
67
+ if (retry_count += 1) < @max_retry_count && tmax > Process.clock_gettime(Process::CLOCK_REALTIME, :second)
67
68
  STDERR.puts "#{$!}\n retrying."
68
69
  sleep 2
69
70
  retry
@@ -75,7 +76,7 @@ module PerfectQueue::Backend
75
76
  if $!.to_s.include?('try restarting transaction')
76
77
  err = $!.backtrace.map{|bt| " #{bt}" }.unshift($!).join("\n")
77
78
  retry_count += 1
78
- if retry_count < MAX_RETRY
79
+ if retry_count < @max_retry_count
79
80
  STDERR.puts "#{err}\n retrying."
80
81
  sleep 0.5
81
82
  retry
@@ -43,6 +43,7 @@ module PerfectQueue
43
43
  super
44
44
 
45
45
  @pq_connect_timeout = config.fetch(:pq_connect_timeout, 20)
46
+ @max_retry_count = config.fetch(:max_retry_count, 10)
46
47
  url = config[:url]
47
48
  @table = config[:table]
48
49
  unless @table
@@ -121,9 +122,9 @@ SQL
121
122
  end
122
123
 
123
124
  attr_reader :db
125
+ attr_reader :max_retry_count
124
126
 
125
127
  KEEPALIVE = 10
126
- MAX_RETRY = 10
127
128
  LOCK_WAIT_TIMEOUT = 10
128
129
  DEFAULT_DELETE_INTERVAL = 20
129
130
 
@@ -373,7 +374,7 @@ SQL
373
374
  yield
374
375
  @last_time = now
375
376
  rescue Sequel::DatabaseConnectionError
376
- if (count += 1) < MAX_RETRY && tmax > Time.now.to_i
377
+ if (count += 1) < @max_retry_count && tmax > Time.now.to_i
377
378
  STDERR.puts "#{$!}\n retrying."
378
379
  sleep 2
379
380
  retry
@@ -385,7 +386,7 @@ SQL
385
386
  if $!.to_s.include?('try restarting transaction')
386
387
  err = ([$!] + $!.backtrace.map {|bt| " #{bt}" }).join("\n")
387
388
  count += 1
388
- if count < MAX_RETRY
389
+ if count < @max_retry_count
389
390
  STDERR.puts err + "\n retrying."
390
391
  sleep rand
391
392
  retry
@@ -1,3 +1,3 @@
1
1
  module PerfectQueue
2
- VERSION = "0.8.52"
2
+ VERSION = "0.8.53"
3
3
  end
@@ -55,7 +55,7 @@ describe Backend::RDBBackend do
55
55
  end
56
56
  context 'error' do
57
57
  it 'returns block result' do
58
- expect(RuntimeError).to receive(:new).exactly(Backend::RDBBackend::MAX_RETRY).and_call_original
58
+ expect(RuntimeError).to receive(:new).exactly(db.max_retry_count).and_call_original
59
59
  allow(STDERR).to receive(:puts)
60
60
  allow(db).to receive(:sleep)
61
61
  expect do
@@ -367,7 +367,7 @@ describe Backend::RDBCompatBackend do
367
367
  end
368
368
  context 'error' do
369
369
  it 'returns block result' do
370
- expect(RuntimeError).to receive(:new).exactly(Backend::RDBCompatBackend::MAX_RETRY).and_call_original
370
+ expect(RuntimeError).to receive(:new).exactly(db.max_retry_count).and_call_original
371
371
  allow(STDERR).to receive(:puts)
372
372
  allow(db).to receive(:sleep)
373
373
  expect do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfectqueue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.52
4
+ version: 0.8.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project:
179
- rubygems_version: 2.5.1
179
+ rubygems_version: 2.5.2.3
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Highly available distributed cron built on RDBMS