Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 #373

Merged
merged 1 commit into from
Jun 2, 2017
Merged

💄 #373

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Metrics/ParameterLists:
Enabled: false

Metrics/LineLength:
Max: 120
Max: 130

Metrics/MethodLength :
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion examples/default_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class DefaultWorker
shoryuken_options queue: 'default', auto_delete: true

def perform(sqs_msg, body)
Shoryuken.logger.debug("Received message: '#{body}'")
Shoryuken.logger.debug("Received message: #{body}")
end
end
4 changes: 2 additions & 2 deletions lib/shoryuken/environment_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def initialize_options
def config_file_options
return {} unless (path = options[:config_file])

fail ArgumentError, "The supplied config file '#{path}' does not exist" unless File.exist?(path)
fail ArgumentError, "The supplied config file #{path} does not exist" unless File.exist?(path)

YAML.load(ERB.new(IO.read(path)).result).deep_symbolize_keys
end
Expand Down Expand Up @@ -141,7 +141,7 @@ def validate_workers
queues_with_workers = Shoryuken.worker_registry.queues

(all_queues - queues_with_workers).each do |queue|
Shoryuken.logger.warn { "No worker supplied for '#{queue}'" }
Shoryuken.logger.warn { "No worker supplied for #{queue}" }
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/shoryuken/fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ class Fetcher
def fetch(queue, available_processors)
started_at = Time.now

logger.debug { "Looking for new messages in '#{queue}'" }
logger.debug { "Looking for new messages in #{queue}" }

begin
limit = available_processors > FETCH_LIMIT ? FETCH_LIMIT : available_processors

sqs_msgs = Array(receive_messages(queue, limit))
logger.info { "Found #{sqs_msgs.size} messages for '#{queue.name}'" } unless sqs_msgs.empty?
logger.debug { "Fetcher for '#{queue}' completed in #{elapsed(started_at)} ms" }
logger.info { "Found #{sqs_msgs.size} messages for #{queue.name}" } unless sqs_msgs.empty?
logger.debug { "Fetcher for #{queue} completed in #{elapsed(started_at)} ms" }
sqs_msgs
rescue => ex
logger.error { "Error fetching message: #{ex}" }
logger.error { ex.backtrace.first }
logger.error { "Error fetching message: #{ex.message}" }
logger.error { ex.backtrace.join("\n") } unless ex.backtrace.nil?
[]
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/shoryuken/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def stop(options = {})
@done.make_true

if (callback = Shoryuken.stop_callback)
logger.info { 'Calling Shoryuken.on_stop block' }
logger.info { 'Calling on_stop callback' }
callback.call
end

Expand All @@ -50,12 +50,12 @@ def stop(options = {})
end

def processor_failed(ex)
logger.error ex
logger.error ex.backtrace.join("\n") unless ex.backtrace.nil?
logger.error { "Processor failed: #{ex.message}" }
logger.error { ex.backtrace.join("\n") } unless ex.backtrace.nil?
end

def processor_done(queue)
logger.debug { "Process done for '#{queue}'" }
logger.debug { "Process done for #{queue}" }
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/middleware/server/auto_extend_visibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def auto_extend(worker, queue, sqs_msg, body)
end

sqs_msg.change_visibility(visibility_timeout: queue_visibility_timeout)
rescue => e
rescue => ex
logger.error do
'Could not auto extend the message ' \
"#{worker_name(worker.class, sqs_msg, body)}/#{queue}/#{sqs_msg.message_id} " \
"visibility timeout. Error: #{e.message}"
"visibility timeout. Error: #{ex.message}"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/middleware/server/exponential_backoff_retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call(worker, queue, sqs_msg, body)

logger.warn { "Message #{sqs_msg.message_id} will attempt retry due to error: #{ex.message}" }
# since we didn't raise, lets log the backtrace for debugging purposes.
logger.debug ex.backtrace.join("\n") unless ex.backtrace.nil?
logger.debug { ex.backtrace.join("\n") } unless ex.backtrace.nil?
end

private
Expand Down Expand Up @@ -51,7 +51,7 @@ def handle_failure(sqs_msg, started_at, retry_intervals)

sqs_msg.change_visibility(visibility_timeout: next_visibility_timeout(interval.to_i, started_at))

logger.info { "Message #{sqs_msg.message_id} failed, will be retried in #{interval} seconds." }
logger.info { "Message #{sqs_msg.message_id} failed, will be retried in #{interval} seconds" }

true
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/middleware/server/timing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def call(worker, queue, sqs_msg, body)
end

logger.info { "completed in: #{total_time} ms" }
rescue => e
rescue
logger.info { "failed in: #{elapsed(started_at)} ms" }
raise e
raise
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/shoryuken/polling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def messages_found(queue, messages_found)
maximum_weight = maximum_queue_weight(queue)
current_weight = current_queue_weight(queue)
if maximum_weight > current_weight
logger.info { "Increasing '#{queue}' weight to #{current_weight + 1}, max: #{maximum_weight}" }
logger.info { "Increasing #{queue} weight to #{current_weight + 1}, max: #{maximum_weight}" }
@queues << queue
end
end
Expand All @@ -103,15 +103,15 @@ def active_queues
def pause(queue)
return unless @queues.delete(queue)
@paused_queues << [Time.now + delay, queue]
logger.debug "Paused '#{queue}'"
logger.debug "Paused #{queue}"
end

def unpause_queues
return if @paused_queues.empty?
return if Time.now < @paused_queues.first[0]
pause = @paused_queues.shift
@queues << pause[1]
logger.debug "Unpaused '#{pause[1]}'"
logger.debug "Unpaused #{pause[1]}"
end

def current_queue_weight(queue)
Expand Down Expand Up @@ -197,7 +197,7 @@ def queue_paused?(queue)
def pause(queue)
return unless delay > 0
@paused_until[queue] = Time.now + delay
logger.debug "Paused '#{queue}'"
logger.debug "Paused #{queue}"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def parse_body(worker_class, sqs_msg)
body_parser.load(sqs_msg.body)
end
end
rescue => e
logger.error { "Error parsing the message body: #{e.message}\nbody_parser: #{body_parser}\nsqs_msg.body: #{sqs_msg.body}" }
rescue => ex
logger.error { "Error parsing the message body: #{ex.message}\nbody_parser: #{body_parser}\nsqs_msg.body: #{sqs_msg.body}" }
raise
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shoryuken/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def initialize(client, name)
self.name = name
self.client = client
self.url = client.get_queue_url(queue_name: name).queue_url
rescue Aws::SQS::Errors::NonExistentQueue => e
raise e, "The specified queue '#{name}' does not exist."
rescue Aws::SQS::Errors::NonExistentQueue => ex
raise ex, "The specified queue #{name} does not exist."
end

def visibility_timeout
Expand Down
2 changes: 1 addition & 1 deletion lib/shoryuken/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def run(options)
@launcher = Shoryuken::Launcher.new

if (callback = Shoryuken.start_callback)
logger.info { 'Calling Shoryuken.on_start block' }
logger.info { 'Calling on_start callback' }
callback.call
end

Expand Down
2 changes: 1 addition & 1 deletion test_workers/endless_uninterruptive_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def random_number(hi = 1000)
end

def perform(sqs_msg, body)
Shoryuken.logger.info("Received message: '#{body}'")
Shoryuken.logger.info("Received message: #{body}")

execution_ms = self.class.random_number(self.class.max_execution_time)
Shoryuken.logger.info("Going to burn metal for #{execution_ms}ms")
Expand Down