Skip to content

Commit

Permalink
Fix when enqueue_at is string for some reason. Fixes sidekiq#1949
Browse files Browse the repository at this point in the history
  • Loading branch information
seuros committed Sep 16, 2014
1 parent 9660ea9 commit 169190d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/sidekiq/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ def jid
end

def enqueued_at
Time.at(@item['enqueued_at'] || 0).utc
fail ArgumentError, 'Invalid value for enqueued_at, must be numeric' unless @item['enqueued_at'].class <= Numeric
Time.at(@item['enqueued_at'].to_f).utc
end

def queue
Expand Down
6 changes: 4 additions & 2 deletions test/test_web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,8 @@ def add_scheduled
score = Time.now.to_f
msg = { 'class' => 'HardWorker',
'args' => ['bob', 1, Time.now.to_f],
'jid' => SecureRandom.hex(12) }
'jid' => SecureRandom.hex(12),
'enqueued_at' => Time.now.to_f}
Sidekiq.redis do |conn|
conn.zadd('schedule', score, Sidekiq.dump_json(msg))
end
Expand All @@ -483,7 +484,8 @@ def add_retry
'error_class' => 'RuntimeError',
'retry_count' => 0,
'failed_at' => Time.now.to_f,
'jid' => SecureRandom.hex(12) }
'jid' => SecureRandom.hex(12),
'enqueued_at' => Time.now.to_f }
score = Time.now.to_f
Sidekiq.redis do |conn|
conn.zadd('retry', score, Sidekiq.dump_json(msg))
Expand Down

0 comments on commit 169190d

Please sign in to comment.