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
0c88414d94
8 changed files with 54 additions and 15 deletions
|
@ -3,10 +3,11 @@ Sidekiq Pro Changelog
|
||||||
|
|
||||||
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how to buy.
|
||||||
|
|
||||||
HEAD
|
3.4.3
|
||||||
---------
|
---------
|
||||||
|
|
||||||
- Update reliable scheduler to enqueue up to 100 jobs per call, minimizing Redis latency [#3332]
|
- Limit reliable scheduler to enqueue up to 100 jobs per call, minimizing Redis latency [#3332]
|
||||||
|
- Fix bug in super\_fetch logic for queues with `_` in the name [#3339]
|
||||||
|
|
||||||
3.4.2
|
3.4.2
|
||||||
---------
|
---------
|
||||||
|
|
|
@ -75,7 +75,10 @@ module Sidekiq
|
||||||
enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+)
|
enqueued = pipe2_res[s..-1].map(&:to_i).inject(0, &:+)
|
||||||
|
|
||||||
default_queue_latency = if (entry = pipe1_res[6].first)
|
default_queue_latency = if (entry = pipe1_res[6].first)
|
||||||
Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at'.freeze]
|
job = Sidekiq.load_json(entry)
|
||||||
|
now = Time.now.to_f
|
||||||
|
thence = job['enqueued_at'.freeze] || now
|
||||||
|
now - thence
|
||||||
else
|
else
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
@ -225,7 +228,10 @@ module Sidekiq
|
||||||
conn.lrange(@rname, -1, -1)
|
conn.lrange(@rname, -1, -1)
|
||||||
end.first
|
end.first
|
||||||
return 0 unless entry
|
return 0 unless entry
|
||||||
Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at']
|
job = Sidekiq.load_json(entry)
|
||||||
|
now = Time.now.to_f
|
||||||
|
thence = job['enqueued_at'] || now
|
||||||
|
now - thence
|
||||||
end
|
end
|
||||||
|
|
||||||
def each
|
def each
|
||||||
|
@ -355,7 +361,8 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def latency
|
def latency
|
||||||
Time.now.to_f - (self['enqueued_at'] || self['created_at'] || 0)
|
now = Time.now.to_f
|
||||||
|
now - (@item['enqueued_at'] || @item['created_at'] || now)
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -592,13 +599,13 @@ module Sidekiq
|
||||||
# Allows enumeration of scheduled jobs within Sidekiq.
|
# Allows enumeration of scheduled jobs within Sidekiq.
|
||||||
# Based on this, you can search/filter for jobs. Here's an
|
# Based on this, you can search/filter for jobs. Here's an
|
||||||
# example where I'm selecting all jobs of a certain type
|
# example where I'm selecting all jobs of a certain type
|
||||||
# and deleting them from the retry queue.
|
# and deleting them from the schedule queue.
|
||||||
#
|
#
|
||||||
# r = Sidekiq::ScheduledSet.new
|
# r = Sidekiq::ScheduledSet.new
|
||||||
# r.select do |retri|
|
# r.select do |scheduled|
|
||||||
# retri.klass == 'Sidekiq::Extensions::DelayedClass' &&
|
# scheduled.klass == 'Sidekiq::Extensions::DelayedClass' &&
|
||||||
# retri.args[0] == 'User' &&
|
# scheduled.args[0] == 'User' &&
|
||||||
# retri.args[1] == 'setup_new_subscriber'
|
# scheduled.args[1] == 'setup_new_subscriber'
|
||||||
# end.map(&:delete)
|
# end.map(&:delete)
|
||||||
class ScheduledSet < JobSet
|
class ScheduledSet < JobSet
|
||||||
def initialize
|
def initialize
|
||||||
|
|
|
@ -281,7 +281,7 @@ module Sidekiq
|
||||||
when :json
|
when :json
|
||||||
{ "Content-Type" => "application/json", "Cache-Control" => "no-cache" }
|
{ "Content-Type" => "application/json", "Cache-Control" => "no-cache" }
|
||||||
when String
|
when String
|
||||||
{ "Content-Type" => action.type, "Cache-Control" => "no-cache" }
|
{ "Content-Type" => (action.type || "text/html"), "Cache-Control" => "no-cache" }
|
||||||
else
|
else
|
||||||
{ "Content-Type" => "text/html", "Cache-Control" => "no-cache" }
|
{ "Content-Type" => "text/html", "Cache-Control" => "no-cache" }
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
require 'uri'
|
require 'uri'
|
||||||
require 'set'
|
require 'set'
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
require 'cgi'
|
||||||
|
|
||||||
module Sidekiq
|
module Sidekiq
|
||||||
# This is not a public API
|
# This is not a public API
|
||||||
|
@ -161,7 +162,7 @@ module Sidekiq
|
||||||
def qparams(options)
|
def qparams(options)
|
||||||
options = options.stringify_keys
|
options = options.stringify_keys
|
||||||
params.merge(options).map do |key, value|
|
params.merge(options).map do |key, value|
|
||||||
SAFE_QPARAMS.include?(key) ? "#{key}=#{value}" : next
|
SAFE_QPARAMS.include?(key) ? "#{key}=#{CGI.escape(value.to_s)}" : next
|
||||||
end.compact.join("&")
|
end.compact.join("&")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ Gem::Specification.new do |gem|
|
||||||
gem.license = "LGPL-3.0"
|
gem.license = "LGPL-3.0"
|
||||||
|
|
||||||
gem.executables = ['sidekiq', 'sidekiqctl']
|
gem.executables = ['sidekiq', 'sidekiqctl']
|
||||||
gem.files = `git ls-files | grep -Ev '^(myapp|examples)'`.split("\n")
|
gem.files = `git ls-files | grep -Ev '^(test|myapp|examples)'`.split("\n")
|
||||||
gem.test_files = `git ls-files -- test/*`.split("\n")
|
gem.test_files = []
|
||||||
gem.name = "sidekiq"
|
gem.name = "sidekiq"
|
||||||
gem.require_paths = ["lib"]
|
gem.require_paths = ["lib"]
|
||||||
gem.version = Sidekiq::VERSION
|
gem.version = Sidekiq::VERSION
|
||||||
|
|
|
@ -16,6 +16,7 @@ class TestApi < Sidekiq::Test
|
||||||
assert_equal 0, s.processed
|
assert_equal 0, s.processed
|
||||||
assert_equal 0, s.failed
|
assert_equal 0, s.failed
|
||||||
assert_equal 0, s.enqueued
|
assert_equal 0, s.enqueued
|
||||||
|
assert_equal 0, s.default_queue_latency
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "processed" do
|
describe "processed" do
|
||||||
|
@ -95,6 +96,28 @@ class TestApi < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "enqueued" do
|
describe "enqueued" do
|
||||||
|
it 'handles latency for good jobs' do
|
||||||
|
Sidekiq.redis do |conn|
|
||||||
|
conn.rpush 'queue:default', "{\"enqueued_at\": #{Time.now.to_f}}"
|
||||||
|
conn.sadd 'queues', 'default'
|
||||||
|
end
|
||||||
|
s = Sidekiq::Stats.new
|
||||||
|
assert s.default_queue_latency > 0
|
||||||
|
q = Sidekiq::Queue.new
|
||||||
|
assert q.latency > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'handles latency for incomplete jobs' do
|
||||||
|
Sidekiq.redis do |conn|
|
||||||
|
conn.rpush 'queue:default', '{}'
|
||||||
|
conn.sadd 'queues', 'default'
|
||||||
|
end
|
||||||
|
s = Sidekiq::Stats.new
|
||||||
|
assert_equal 0, s.default_queue_latency
|
||||||
|
q = Sidekiq::Queue.new
|
||||||
|
assert_equal 0, q.latency
|
||||||
|
end
|
||||||
|
|
||||||
it "returns total enqueued jobs" do
|
it "returns total enqueued jobs" do
|
||||||
Sidekiq.redis do |conn|
|
Sidekiq.redis do |conn|
|
||||||
conn.rpush 'queue:foo', '{}'
|
conn.rpush 'queue:foo', '{}'
|
||||||
|
|
|
@ -219,6 +219,7 @@ class TestWeb < Sidekiq::Test
|
||||||
visit "/retries/#{job_params(*params)}"
|
visit "/retries/#{job_params(*params)}"
|
||||||
assert_equal 200, page.status_code
|
assert_equal 200, page.status_code
|
||||||
assert_text('HardWorker')
|
assert_text('HardWorker')
|
||||||
|
assert_text('RuntimeError')
|
||||||
snapshot(page, name: 'Single Retry Page')
|
snapshot(page, name: 'Single Retry Page')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -556,6 +557,12 @@ class TestWeb < Sidekiq::Test
|
||||||
assert_equal 200, last_response.status
|
assert_equal 200, last_response.status
|
||||||
assert_match(/#{params.first['args'][2]}/, last_response.body)
|
assert_match(/#{params.first['args'][2]}/, last_response.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'handles bad query input' do
|
||||||
|
get '/queues/foo?page=B<H'
|
||||||
|
assert_equal 200, last_response.status
|
||||||
|
assert_match(/B%3CH/, last_response.body)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_scheduled(job_id=SecureRandom.hex(12))
|
def add_scheduled(job_id=SecureRandom.hex(12))
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t('ErrorClass') %></th>
|
<th><%= t('ErrorClass') %></th>
|
||||||
<td>
|
<td>
|
||||||
<code><%= h @retry.display_class %></code>
|
<code><%= h @retry['error_class'] %></code>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in a new issue