mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
merge master
This commit is contained in:
commit
5806792716
9 changed files with 51 additions and 36 deletions
|
@ -20,6 +20,9 @@ Sidekiq::Middleware::Server::Logging -> Sidekiq::JobLogging
|
|||
master
|
||||
-----------
|
||||
|
||||
- Scheduled jobs can now be moved directly to the Dead queue via API [#3390]
|
||||
- Fix edge case leading to job duplication when using Sidekiq Pro's
|
||||
reliability feature [#3388]
|
||||
- Fix error class name display on retry page [#3348]
|
||||
- More robust latency calculation [#3340]
|
||||
|
||||
|
|
|
@ -3,6 +3,11 @@ Sidekiq Pro Changelog
|
|||
|
||||
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
||||
|
||||
HEAD
|
||||
---------
|
||||
|
||||
- Make Batch UI progress bar more friendly to the colorblind [#3387]
|
||||
|
||||
3.4.5
|
||||
---------
|
||||
|
||||
|
|
|
@ -430,10 +430,9 @@ module Sidekiq
|
|||
end
|
||||
|
||||
def retry
|
||||
raise "Retry not available on jobs which have not failed" unless item["failed_at"]
|
||||
remove_job do |message|
|
||||
msg = Sidekiq.load_json(message)
|
||||
msg['retry_count'] -= 1
|
||||
msg['retry_count'] -= 1 if msg['retry_count']
|
||||
Sidekiq::Client.push(msg)
|
||||
end
|
||||
end
|
||||
|
@ -441,9 +440,7 @@ module Sidekiq
|
|||
##
|
||||
# Place job in the dead set
|
||||
def kill
|
||||
raise 'Kill not available on jobs which have not failed' unless item['failed_at']
|
||||
remove_job do |message|
|
||||
Sidekiq.logger.info { "Killing job #{message['jid']}" }
|
||||
now = Time.now.to_f
|
||||
Sidekiq.redis do |conn|
|
||||
conn.multi do
|
||||
|
@ -455,6 +452,10 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
|
||||
def error?
|
||||
!!item['error_class']
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_job
|
||||
|
|
|
@ -2,28 +2,19 @@ module Sidekiq
|
|||
class JobLogger
|
||||
|
||||
def call(item, queue)
|
||||
Sidekiq::Logging.with_context(log_context(item)) do
|
||||
begin
|
||||
start = Time.now
|
||||
logger.info("start".freeze)
|
||||
yield
|
||||
logger.info("done: #{elapsed(start)} sec")
|
||||
rescue Exception
|
||||
logger.info("fail: #{elapsed(start)} sec")
|
||||
raise
|
||||
end
|
||||
begin
|
||||
start = Time.now
|
||||
logger.info("start".freeze)
|
||||
yield
|
||||
logger.info("done: #{elapsed(start)} sec")
|
||||
rescue Exception
|
||||
logger.info("fail: #{elapsed(start)} sec")
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# If we're using a wrapper class, like ActiveJob, use the "wrapped"
|
||||
# attribute to expose the underlying thing.
|
||||
def log_context(item)
|
||||
klass = item['wrapped'.freeze] || item["class".freeze]
|
||||
"#{klass} JID-#{item['jid'.freeze]}#{" BID-#{item['bid'.freeze]}" if item['bid'.freeze]}"
|
||||
end
|
||||
|
||||
def elapsed(start)
|
||||
(Time.now - start).round(3)
|
||||
end
|
||||
|
|
|
@ -125,19 +125,26 @@ module Sidekiq
|
|||
# job structure to the Web UI
|
||||
pristine = cloned(job_hash)
|
||||
|
||||
@retrier.global(job_hash, queue) do
|
||||
@logging.call(job_hash, queue) do
|
||||
stats(pristine, queue) do
|
||||
# Rails 5 requires a Reloader to wrap code execution. In order to
|
||||
# constantize the worker and instantiate an instance, we have to call
|
||||
# the Reloader. It handles code loading, db connection management, etc.
|
||||
# Effectively this block denotes a "unit of work" to Rails.
|
||||
@reloader.call do
|
||||
klass = job_hash['class'.freeze].constantize
|
||||
worker = klass.new
|
||||
worker.jid = job_hash['jid'.freeze]
|
||||
@retrier.local(worker, job_hash, queue) do
|
||||
yield worker
|
||||
# If we're using a wrapper class, like ActiveJob, use the "wrapped"
|
||||
# attribute to expose the underlying thing.
|
||||
klass = job_hash['wrapped'.freeze] || job_hash["class".freeze]
|
||||
ctx = "#{klass} JID-#{job_hash['jid'.freeze]}#{" BID-#{job_hash['bid'.freeze]}" if job_hash['bid'.freeze]}"
|
||||
|
||||
Sidekiq::Logging.with_context(ctx) do
|
||||
@retrier.global(job_hash, queue) do
|
||||
@logging.call(job_hash, queue) do
|
||||
stats(pristine, queue) do
|
||||
# Rails 5 requires a Reloader to wrap code execution. In order to
|
||||
# constantize the worker and instantiate an instance, we have to call
|
||||
# the Reloader. It handles code loading, db connection management, etc.
|
||||
# Effectively this block denotes a "unit of work" to Rails.
|
||||
@reloader.call do
|
||||
klass = job_hash['class'.freeze].constantize
|
||||
worker = klass.new
|
||||
worker.jid = job_hash['jid'.freeze]
|
||||
@retrier.local(worker, job_hash, queue) do
|
||||
yield worker
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -316,3 +316,9 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(::Rails) && !Rails.env.test?
|
||||
puts("**************************************************")
|
||||
puts("⛔️ WARNING: Sidekiq testing API enabled, but this is not the test environment. Your jobs will not go to Redis.")
|
||||
puts("**************************************************")
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Sidekiq
|
||||
VERSION = "5.0.0.beta2"
|
||||
VERSION = "5.0.0.beta3"
|
||||
end
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<% if type == :dead %>
|
||||
<tr>
|
||||
<th><%= t('LastRetry') %></th>
|
||||
<td><%= relative_time(job.at) %></td>
|
||||
<td><%= relative_time(job.at) if job['retry_count'] %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
|
|
@ -47,7 +47,9 @@
|
|||
<div class="args"><%= display_args(entry.display_args) %></div>
|
||||
</td>
|
||||
<td>
|
||||
<% if entry.error? %>
|
||||
<div><%= h truncate("#{entry['error_class']}: #{entry['error_message']}", 200) %></div>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Reference in a new issue