1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Rename Sidekiq::Job, reserve for future use

This commit is contained in:
Mike Perham 2021-08-19 13:07:47 -07:00
parent 69b2aec57b
commit f1b24da9c2
6 changed files with 14 additions and 13 deletions

View file

@ -10,6 +10,7 @@
- Improve logging of delay jobs [#4904, BuonOno]
- Minor CSS improvements for buttons and tables, design PRs always welcome!
- Tweak Web UI `Cache-Control` header [#4966]
- Rename internal API class `Sidekiq::Job` to `Sidekiq::JobRecord` [#4955]
6.2.1
---------

View file

@ -267,7 +267,7 @@ module Sidekiq
break if entries.empty?
page += 1
entries.each do |entry|
yield Job.new(entry, @name)
yield JobRecord.new(entry, @name)
end
deleted_size = initial_size - size
end
@ -298,9 +298,9 @@ module Sidekiq
# sorted set.
#
# The job should be considered immutable but may be
# removed from the queue via Job#delete.
# removed from the queue via JobRecord#delete.
#
class Job
class JobRecord
attr_reader :item
attr_reader :value
@ -457,7 +457,7 @@ module Sidekiq
end
end
class SortedEntry < Job
class SortedEntry < JobRecord
attr_reader :score
attr_reader :parent
@ -837,11 +837,11 @@ module Sidekiq
# For Sidekiq Enterprise customers this number (in production) must be
# less than or equal to your licensed concurrency.
def total_concurrency
sum { |x| x["concurrency"] }
sum { |x| x["concurrency"].to_i }
end
def total_rss_in_kb
sum { |x| x["rss"] || 0 }
sum { |x| x["rss"].to_i }
end
alias_method :total_rss, :total_rss_in_kb

View file

@ -92,7 +92,7 @@ module Sidekiq
@count = (params["count"] || 25).to_i
@queue = Sidekiq::Queue.new(@name)
(@current_page, @total_size, @messages) = page("queue:#{@name}", params["page"], @count, reverse: params["direction"] == "asc")
@messages = @messages.map { |msg| Sidekiq::Job.new(msg, @name) }
@messages = @messages.map { |msg| Sidekiq::JobRecord.new(msg, @name) }
erb(:queue)
end
@ -113,7 +113,7 @@ module Sidekiq
post "/queues/:name/delete" do
name = route_params[:name]
Sidekiq::Job.new(params["key_val"], name).delete
Sidekiq::JobRecord.new(params["key_val"], name).delete
redirect_with_query("#{root_path}queues/#{CGI.escape(name)}")
end

View file

@ -308,7 +308,7 @@ describe 'API' do
it "unwraps ActiveJob #{ver} jobs" do
#ApiJob.perform_later(1,2,3)
#puts Sidekiq::Queue.new.first.value
x = Sidekiq::Job.new(jobs[0], "default")
x = Sidekiq::JobRecord.new(jobs[0], "default")
assert_equal ApiJob.name, x.display_class
assert_equal [1,2,3], x.display_args
end
@ -316,7 +316,7 @@ describe 'API' do
it "unwraps ActionMailer #{ver} jobs" do
#ApiMailer.test_email(1,2,3).deliver_later
#puts Sidekiq::Queue.new("mailers").first.value
x = Sidekiq::Job.new(jobs[1], "mailers")
x = Sidekiq::JobRecord.new(jobs[1], "mailers")
assert_equal "#{ApiMailer.name}#test_email", x.display_class
assert_equal [1,2,3], x.display_args
end

View file

@ -65,7 +65,7 @@ describe Sidekiq::Web do
Sidekiq.redis do |conn|
conn.incr('busy')
conn.sadd('processes', 'foo:1234')
conn.hmset('foo:1234', 'info', Sidekiq.dump_json('hostname' => 'foo', 'started_at' => Time.now.to_f, "queues" => []), 'at', Time.now.to_f, 'busy', 4)
conn.hmset('foo:1234', 'info', Sidekiq.dump_json('hostname' => 'foo', 'started_at' => Time.now.to_f, "queues" => [], 'concurrency' => 10), 'at', Time.now.to_f, 'busy', 4)
identity = 'foo:1234:workers'
hash = {:queue => 'critical', :payload => { 'class' => WebWorker.name, 'args' => [1,'abc'] }, :run_at => Time.now.to_i }
conn.hmset(identity, 1001, Sidekiq.dump_json(hash))
@ -451,7 +451,7 @@ describe Sidekiq::Web do
Sidekiq.redis do |conn|
pro = 'foo:1234'
conn.sadd('processes', pro)
conn.hmset(pro, 'info', Sidekiq.dump_json('started_at' => Time.now.to_f, 'labels' => ['frumduz'], 'queues' =>[]), 'busy', 1, 'beat', Time.now.to_f)
conn.hmset(pro, 'info', Sidekiq.dump_json('started_at' => Time.now.to_f, 'labels' => ['frumduz'], 'queues' =>[], 'concurrency' => 10), 'busy', 1, 'beat', Time.now.to_f)
identity = "#{pro}:workers"
hash = {:queue => 'critical', :payload => { 'class' => "FailWorker", 'args' => ["<a>hello</a>"] }, :run_at => Time.now.to_i }
conn.hmset(identity, 100001, Sidekiq.dump_json(hash))

View file

@ -110,7 +110,7 @@
<th><%= t('Started') %></th>
</thead>
<% workers.each do |process, thread, msg| %>
<% job = Sidekiq::Job.new(msg['payload']) %>
<% job = Sidekiq::JobRecord.new(msg['payload']) %>
<tr>
<td><%= process %></td>
<td><%= thread %></td>