Skip to content

Commit

Permalink
Merge branch 'master' into 3-0
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Feb 9, 2014
2 parents d355a04 + 10bccba commit 2e1ffbc
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions Changes.md
Expand Up @@ -19,6 +19,7 @@
2.17.5
-----------

- 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]
Expand Down
2 changes: 1 addition & 1 deletion config.ru
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/sidekiq/middleware/server/retry_jobs.rb
Expand Up @@ -75,10 +75,10 @@ def call(worker, msg, queue)
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

Expand Down
2 changes: 1 addition & 1 deletion test/test_api.rb
Expand Up @@ -380,7 +380,7 @@ class ApiWorker
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
Expand Down
10 changes: 5 additions & 5 deletions test/test_retry.rb
Expand Up @@ -129,7 +129,7 @@ def @redis.with; yield self; end

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
Expand All @@ -147,7 +147,7 @@ def @redis.with; yield self; end

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
Expand All @@ -164,7 +164,7 @@ def @redis.with; yield self; end
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
Expand All @@ -178,7 +178,7 @@ def @redis.with; yield self; end
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
Expand All @@ -194,7 +194,7 @@ def @redis.with; yield self; end
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 block" do
let(:worker) do
Expand Down
4 changes: 2 additions & 2 deletions test/test_web.rb
Expand Up @@ -423,7 +423,7 @@ def add_retry
'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|
Expand Down Expand Up @@ -455,7 +455,7 @@ def add_xss_retry
'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|
Expand Down
2 changes: 1 addition & 1 deletion web/locales/fr.yml
Expand Up @@ -2,7 +2,7 @@
fr:
Dashboard: Tableau de Bord
Status: État
Time: Temps
Time: Heure
Namespace: Namespace
Realtime: Temps Réel
History: Historique
Expand Down

0 comments on commit 2e1ffbc

Please sign in to comment.