Class: AuctionFunCore::Workers::ApplicationJob Abstract

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
lib/auction_fun_core/workers/application_job.rb

Overview

This class is abstract.

Abstract base class for background jobs.

Constant Summary collapse

MAX_RETRIES =
15

Instance Method Summary collapse

Instance Method Details

#backoff_exponential_job(retry_count, measure = "seconds") ⇒ Integer

Calculates an exponential backoff interval for retrying the job.

Parameters:

  • retry_count (Integer)

    The current retry count.

  • measure (String) (defaults to: "seconds")

    The unit of time to measure the interval.

Returns:

  • (Integer)

    The backoff interval in the specified measure.



27
28
29
30
31
# File 'lib/auction_fun_core/workers/application_job.rb', line 27

def backoff_exponential_job(retry_count, measure = "seconds")
  max_retries = Float(2**retry_count)

  rand(0..max_retries).send(measure)
end

#capture_exception(exception, attributes = {}) ⇒ void

This method returns an undefined value.

Captures an exception and logs it along with additional attributes.

Parameters:

  • exception (Exception)

    The exception to be captured.

  • attributes (Hash) (defaults to: {})

    Additional attributes to be logged.



18
19
20
# File 'lib/auction_fun_core/workers/application_job.rb', line 18

def capture_exception(exception, attributes = {})
  Application[:logger].error("#{exception.message}. Parameters: #{attributes}")
end