Skip to content

Commit

Permalink
Rename Sidekiq::Job, reserve for future use
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Aug 20, 2021
1 parent 69b2aec commit f1b24da
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------
Expand Down
12 changes: 6 additions & 6 deletions lib/sidekiq/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def each
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
Expand Down Expand Up @@ -298,9 +298,9 @@ def clear
# 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

Expand Down Expand Up @@ -457,7 +457,7 @@ def uncompress_backtrace(backtrace)
end
end

class SortedEntry < Job
class SortedEntry < JobRecord
attr_reader :score
attr_reader :parent

Expand Down Expand Up @@ -837,11 +837,11 @@ def size
# 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

Expand Down
4 changes: 2 additions & 2 deletions lib/sidekiq/web/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def self.set(key, val)
@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
Expand All @@ -113,7 +113,7 @@ def self.set(key, val)

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
Expand Down
4 changes: 2 additions & 2 deletions test/test_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ class WorkerWithTags
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

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
Expand Down
4 changes: 2 additions & 2 deletions test/test_web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def perform(a, b)
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))
Expand Down Expand Up @@ -451,7 +451,7 @@ def perform(a, b)
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))
Expand Down
2 changes: 1 addition & 1 deletion web/views/busy.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit f1b24da

Please sign in to comment.