Class: SidekiqUniqueJobs::OnConflict::Reschedule

Inherits:
Strategy
  • Object
show all
Includes:
JSON, Logging, SidekiqWorkerMethods
Defined in:
lib/sidekiq_unique_jobs/on_conflict/reschedule.rb

Overview

Strategy to reschedule job on conflict

Author:

Instance Attribute Summary

Attributes inherited from Strategy

#item, #redis_pool

Instance Method Summary collapse

Methods included from JSON

dump_json, load_json

Methods included from Logging

included, #log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context, #with_configured_loggers_context, #with_logging_context

Methods included from SidekiqWorkerMethods

#after_unlock_hook, #default_worker_options, #sidekiq_worker_class?, #worker_class, #worker_class_constantize, #worker_method_defined?, #worker_options

Methods inherited from Strategy

#replace?

Methods included from Timing

clock_stamp, now_f, time_source, timed

Methods included from Script::Caller

call_script, debug_lua, do_call, extract_args, max_history, now_f, redis_version

Constructor Details

#initialize(item, redis_pool = nil) ⇒ Reschedule

Returns a new instance of Reschedule.

Parameters:

  • item (Hash)

    sidekiq job hash



14
15
16
17
# File 'lib/sidekiq_unique_jobs/on_conflict/reschedule.rb', line 14

def initialize(item, redis_pool = nil)
  super(item, redis_pool)
  @worker_class = item[CLASS]
end

Instance Method Details

#callObject

Create a new job from the current one.

This will mess up sidekiq stats because a new job is created


21
22
23
24
25
26
27
28
# File 'lib/sidekiq_unique_jobs/on_conflict/reschedule.rb', line 21

def call
  if sidekiq_worker_class?
    log_info("Rescheduling #{item[LOCK_DIGEST]}")
    worker_class.perform_in(5, *item[ARGS])
  else
    log_warn("Skip rescheduling of #{item[LOCK_DIGEST]} because #{worker_class} is not a Sidekiq::Worker")
  end
end