mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Store timestamps as floats, not strings, fixes #1473
This commit is contained in:
parent
f46ab468f8
commit
2f4d3686ec
6 changed files with 12 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
HEAD
|
||||
-----------
|
||||
|
||||
- Store 'retried\_at' and 'failed\_at' timestamps as Floats, not Strings. [#1473]
|
||||
- A `USR2` signal will now reopen _all_ logs, using IO#reopen. Thus, instead of creating a new Logger object,
|
||||
Sidekiq will now just update the existing Logger's file descriptor [#1163].
|
||||
- Remove pidfile when shutting down if started with `-P` [#1470]
|
||||
|
|
|
@ -12,7 +12,7 @@ end
|
|||
#Sidekiq.redis { |conn| conn.zadd('retry', Time.now.utc.to_f + 3000, MultiJson.encode({
|
||||
#'class' => 'HardWorker', 'args' => ['foo', 0.1, Time.now.to_f],
|
||||
#'queue' => 'default', 'error_message' => 'No such method', 'error_class' => 'NoMethodError',
|
||||
#'failed_at' => Time.now.utc, 'retry_count' => 0 })) }
|
||||
#'failed_at' => Time.now.to_i, 'retry_count' => 0 })) }
|
||||
|
||||
require 'sidekiq/web'
|
||||
run Sidekiq::Web
|
||||
|
|
|
@ -75,10 +75,10 @@ module Sidekiq
|
|||
msg['error_message'] = e.message
|
||||
msg['error_class'] = e.class.name
|
||||
count = if msg['retry_count']
|
||||
msg['retried_at'] = Time.now.utc
|
||||
msg['retried_at'] = Time.now.to_f
|
||||
msg['retry_count'] += 1
|
||||
else
|
||||
msg['failed_at'] = Time.now.utc
|
||||
msg['failed_at'] = Time.now.to_f
|
||||
msg['retry_count'] = 0
|
||||
end
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ class TestApi < Sidekiq::Test
|
|||
end
|
||||
|
||||
def add_retry(jid = 'bob', at = Time.now.to_f)
|
||||
payload = Sidekiq.dump_json('class' => 'ApiWorker', 'args' => [1, 'mike'], 'queue' => 'default', 'jid' => jid, 'retry_count' => 2, 'failed_at' => Time.now.utc)
|
||||
payload = Sidekiq.dump_json('class' => 'ApiWorker', 'args' => [1, 'mike'], 'queue' => 'default', 'jid' => jid, 'retry_count' => 2, 'failed_at' => Time.now.to_f)
|
||||
Sidekiq.redis do |conn|
|
||||
conn.zadd('retry', at.to_s, payload)
|
||||
end
|
||||
|
|
|
@ -129,7 +129,7 @@ class TestRetry < Sidekiq::Test
|
|||
|
||||
it 'handles a recurring failed message' do
|
||||
@redis.expect :zadd, 1, ['retry', String, String]
|
||||
now = Time.now.utc
|
||||
now = Time.now.to_f
|
||||
msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], 'retry' => true, "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry_count"=>10}
|
||||
handler = Sidekiq::Middleware::Server::RetryJobs.new
|
||||
assert_raises RuntimeError do
|
||||
|
@ -147,7 +147,7 @@ class TestRetry < Sidekiq::Test
|
|||
|
||||
it 'handles a recurring failed message before reaching user-specifed max' do
|
||||
@redis.expect :zadd, 1, ['retry', String, String]
|
||||
now = Time.now.utc
|
||||
now = Time.now.to_f
|
||||
msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], 'retry' => 10, "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry_count"=>8}
|
||||
handler = Sidekiq::Middleware::Server::RetryJobs.new
|
||||
assert_raises RuntimeError do
|
||||
|
@ -164,7 +164,7 @@ class TestRetry < Sidekiq::Test
|
|||
end
|
||||
|
||||
it 'throws away old messages after too many retries (using the default)' do
|
||||
now = Time.now.utc
|
||||
now = Time.now.to_f
|
||||
msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry"=>true, "retry_count"=>25}
|
||||
@redis.expect :zadd, 1, [ 'retry', String, String ]
|
||||
handler = Sidekiq::Middleware::Server::RetryJobs.new
|
||||
|
@ -178,7 +178,7 @@ class TestRetry < Sidekiq::Test
|
|||
end
|
||||
|
||||
it 'throws away old messages after too many retries (using user-specified max)' do
|
||||
now = Time.now.utc
|
||||
now = Time.now.to_f
|
||||
msg = {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>now, "retry"=>3, "retry_count"=>3}
|
||||
@redis.expect :zadd, 1, [ 'retry', String, String ]
|
||||
handler = Sidekiq::Middleware::Server::RetryJobs.new
|
||||
|
@ -194,7 +194,7 @@ class TestRetry < Sidekiq::Test
|
|||
describe "retry exhaustion" do
|
||||
let(:handler){ Sidekiq::Middleware::Server::RetryJobs.new }
|
||||
let(:worker) { Minitest::Mock.new }
|
||||
let(:msg){ {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>Time.now.utc, "retry"=>3, "retry_count"=>3} }
|
||||
let(:msg){ {"class"=>"Bob", "args"=>[1, 2, "foo"], "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "failed_at"=>Time.now.to_f, "retry"=>3, "retry_count"=>3} }
|
||||
|
||||
describe "worker method" do
|
||||
let(:worker) do
|
||||
|
|
|
@ -412,7 +412,7 @@ class TestWeb < Sidekiq::Test
|
|||
'error_message' => 'Some fake message',
|
||||
'error_class' => 'RuntimeError',
|
||||
'retry_count' => 0,
|
||||
'failed_at' => Time.now.utc,
|
||||
'failed_at' => Time.now.to_f,
|
||||
'jid' => SecureRandom.hex(12) }
|
||||
score = Time.now.to_f
|
||||
Sidekiq.redis do |conn|
|
||||
|
@ -428,7 +428,7 @@ class TestWeb < Sidekiq::Test
|
|||
'error_message' => 'fail message: <a>hello</a>',
|
||||
'error_class' => 'RuntimeError',
|
||||
'retry_count' => 0,
|
||||
'failed_at' => Time.now.utc,
|
||||
'failed_at' => Time.now.to_f,
|
||||
'jid' => SecureRandom.hex(12) }
|
||||
score = Time.now.to_f
|
||||
Sidekiq.redis do |conn|
|
||||
|
|
Loading…
Reference in a new issue