module Phobos::Processor
Constants
- MAX_SLEEP_INTERVAL
Public Instance Methods
snooze(interval)
click to toggle source
# File lib/phobos/processor.rb, line 12 def snooze(interval) remaining_interval = interval @listener.send_heartbeat_if_necessary while remaining_interval.positive? sleep [remaining_interval, MAX_SLEEP_INTERVAL].min remaining_interval -= MAX_SLEEP_INTERVAL @listener.send_heartbeat_if_necessary end end
Private Instance Methods
backoff()
click to toggle source
# File lib/phobos/processor.rb, line 59 def backoff @backoff ||= @listener.create_exponential_backoff end
backoff_interval()
click to toggle source
# File lib/phobos/processor.rb, line 63 def backoff_interval backoff.interval_at(retry_count).round(2) end
force_encoding(value)
click to toggle source
# File lib/phobos/processor.rb, line 26 def force_encoding(value) @listener.encoding ? value&.force_encoding(@listener.encoding) : value end
handle_error(error, instrumentation_key, error_message)
click to toggle source
# File lib/phobos/processor.rb, line 30 def handle_error(error, instrumentation_key, error_message) error_hash = { waiting_time: backoff_interval, exception_class: error.class.name, exception_message: error.message, backtrace: error.backtrace } instrument(instrumentation_key, error_hash.merge(@metadata)) do Phobos.logger.error do { message: error_message } .merge(error_hash) .merge(@metadata) end snooze(backoff_interval) end increment_retry_count end
increment_retry_count()
click to toggle source
# File lib/phobos/processor.rb, line 55 def increment_retry_count @metadata[:retry_count] = retry_count + 1 end
retry_count()
click to toggle source
# File lib/phobos/processor.rb, line 51 def retry_count @metadata[:retry_count] end