mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Further style improvements
This commit is contained in:
parent
b70c3ef50d
commit
2d0bff6351
5 changed files with 15 additions and 15 deletions
|
@ -382,7 +382,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def size
|
def size
|
||||||
Sidekiq.redis {|c| c.zcard(name) }
|
Sidekiq.redis { |c| c.zcard(name) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear
|
def clear
|
||||||
|
@ -411,7 +411,7 @@ module Sidekiq
|
||||||
range_start = page * page_size + offset_size
|
range_start = page * page_size + offset_size
|
||||||
range_end = page * page_size + offset_size + (page_size - 1)
|
range_end = page * page_size + offset_size + (page_size - 1)
|
||||||
elements = Sidekiq.redis do |conn|
|
elements = Sidekiq.redis do |conn|
|
||||||
conn.zrange name, range_start, range_end, :with_scores => true
|
conn.zrange name, range_start, range_end, with_scores: true
|
||||||
end
|
end
|
||||||
break if elements.empty?
|
break if elements.empty?
|
||||||
page -= 1
|
page -= 1
|
||||||
|
|
|
@ -143,7 +143,7 @@ module Sidekiq
|
||||||
worker.sidekiq_retries_exhausted_block.call(msg)
|
worker.sidekiq_retries_exhausted_block.call(msg)
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
handle_exception(e, { :context => "Error calling retries_exhausted for #{worker.class}", :job => msg })
|
handle_exception(e, { context: "Error calling retries_exhausted for #{worker.class}", job: msg })
|
||||||
end
|
end
|
||||||
|
|
||||||
send_to_morgue(msg) unless msg['dead'] == false
|
send_to_morgue(msg) unless msg['dead'] == false
|
||||||
|
@ -183,7 +183,7 @@ module Sidekiq
|
||||||
begin
|
begin
|
||||||
worker.sidekiq_retry_in_block.call(count)
|
worker.sidekiq_retry_in_block.call(count)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
handle_exception(e, { :context => "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
handle_exception(e, { context: "Failure scheduling retry using the defined `sidekiq_retry_in` in #{worker.class.name}, falling back to default" })
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,7 +14,7 @@ module Sidekiq
|
||||||
def watchdog(last_words)
|
def watchdog(last_words)
|
||||||
yield
|
yield
|
||||||
rescue Exception => ex
|
rescue Exception => ex
|
||||||
handle_exception(ex, { :context => last_words })
|
handle_exception(ex, { context: last_words })
|
||||||
raise ex
|
raise ex
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ module Sidekiq
|
||||||
begin
|
begin
|
||||||
block.call
|
block.call
|
||||||
rescue => ex
|
rescue => ex
|
||||||
handle_exception(ex, { :event => event })
|
handle_exception(ex, { event: event })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,7 +69,7 @@ module Sidekiq
|
||||||
@name = params[:name]
|
@name = params[:name]
|
||||||
@queue = Sidekiq::Queue.new(@name)
|
@queue = Sidekiq::Queue.new(@name)
|
||||||
(@current_page, @total_size, @messages) = page("queue:#{@name}", params[:page], @count)
|
(@current_page, @total_size, @messages) = page("queue:#{@name}", params[:page], @count)
|
||||||
@messages = @messages.map {|msg| Sidekiq::Job.new(msg, @name) }
|
@messages = @messages.map { |msg| Sidekiq::Job.new(msg, @name) }
|
||||||
erb :queue
|
erb :queue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,8 +85,8 @@ module Sidekiq
|
||||||
|
|
||||||
get '/morgue' do
|
get '/morgue' do
|
||||||
@count = (params[:count] || 25).to_i
|
@count = (params[:count] || 25).to_i
|
||||||
(@current_page, @total_size, @dead) = page("dead", params[:page], @count, :reverse => true)
|
(@current_page, @total_size, @dead) = page("dead", params[:page], @count, reverse: true)
|
||||||
@dead = @dead.map {|msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
@dead = @dead.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
||||||
erb :morgue
|
erb :morgue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ module Sidekiq
|
||||||
get '/retries' do
|
get '/retries' do
|
||||||
@count = (params[:count] || 25).to_i
|
@count = (params[:count] || 25).to_i
|
||||||
(@current_page, @total_size, @retries) = page("retry", params[:page], @count)
|
(@current_page, @total_size, @retries) = page("retry", params[:page], @count)
|
||||||
@retries = @retries.map {|msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
@retries = @retries.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
||||||
erb :retries
|
erb :retries
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ module Sidekiq
|
||||||
get '/scheduled' do
|
get '/scheduled' do
|
||||||
@count = (params[:count] || 25).to_i
|
@count = (params[:count] || 25).to_i
|
||||||
(@current_page, @total_size, @scheduled) = page("schedule", params[:page], @count)
|
(@current_page, @total_size, @scheduled) = page("schedule", params[:page], @count)
|
||||||
@scheduled = @scheduled.map {|msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
@scheduled = @scheduled.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
||||||
erb :scheduled
|
erb :scheduled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ module Sidekiq
|
||||||
end
|
end
|
||||||
|
|
||||||
def namespace
|
def namespace
|
||||||
@@ns ||= Sidekiq.redis {|conn| conn.respond_to?(:namespace) ? conn.namespace : nil }
|
@@ns ||= Sidekiq.redis { |conn| conn.respond_to?(:namespace) ? conn.namespace : nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
def redis_info
|
def redis_info
|
||||||
|
@ -110,9 +110,9 @@ module Sidekiq
|
||||||
# Merge options with current params, filter safe params, and stringify to query string
|
# Merge options with current params, filter safe params, and stringify to query string
|
||||||
def qparams(options)
|
def qparams(options)
|
||||||
options = options.stringify_keys
|
options = options.stringify_keys
|
||||||
params.merge(options).map { |key, value|
|
params.merge(options).map do |key, value|
|
||||||
SAFE_QPARAMS.include?(key) ? "#{key}=#{value}" : next
|
SAFE_QPARAMS.include?(key) ? "#{key}=#{value}" : next
|
||||||
}.join("&")
|
end.join("&")
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate(text, truncate_after_chars = 2000)
|
def truncate(text, truncate_after_chars = 2000)
|
||||||
|
@ -147,7 +147,7 @@ module Sidekiq
|
||||||
return number
|
return number
|
||||||
end
|
end
|
||||||
|
|
||||||
options = {:delimiter => ',', :separator => '.'}
|
options = {delimiter: ',', separator: '.'}
|
||||||
parts = number.to_s.to_str.split('.')
|
parts = number.to_s.to_str.split('.')
|
||||||
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
|
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{options[:delimiter]}")
|
||||||
parts.join(options[:separator])
|
parts.join(options[:separator])
|
||||||
|
|
Loading…
Reference in a new issue