Module: JobContracts::SidekiqContractable

Extended by:
ActiveSupport::Concern
Includes:
Contractable
Defined in:
lib/job_contracts/concerns/sidekiq_contractable.rb

Overview

Sidekiq mixin for jobs/workers

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Contractable

#breached_contracts, #contract_breached!

Instance Method Details

#argumentsObject

Matches the ActiveJob API



35
36
37
# File 'lib/job_contracts/concerns/sidekiq_contractable.rb', line 35

def arguments
  sidekiq_job_hash["args"] || []
end

#enqueued_atObject

Matches the ActiveJob API



29
30
31
32
# File 'lib/job_contracts/concerns/sidekiq_contractable.rb', line 29

def enqueued_at
  seconds = sidekiq_job_hash["enqueued_at"]
  (seconds ? Time.at(seconds) : nil)&.iso8601.to_s
end

#queue_nameObject

Matches the ActiveJob API



24
25
26
# File 'lib/job_contracts/concerns/sidekiq_contractable.rb', line 24

def queue_name
  sidekiq_job_hash["queue"]
end

#sidekiq_job_hashObject

Metadata used to enqueue the job



19
20
21
# File 'lib/job_contracts/concerns/sidekiq_contractable.rb', line 19

def sidekiq_job_hash
  @sidekiq_job_hash ||= {}
end