Class: SidekiqUniqueJobs::OnConflict::Strategy Abstract

Inherits:
Object
  • Object
show all
Includes:
JSON, Logging, Script::Caller, Timing
Defined in:
lib/sidekiq_unique_jobs/on_conflict/strategy.rb

Overview

This class is abstract.

Abstract conflict strategy class

Author:

Direct Known Subclasses

Log, NullStrategy, Raise, Reject, Replace, Reschedule

Instance Attribute Summary collapse

Instance Method Summary collapse

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, normalize_argv, now_f, redis_version

Methods included from Logging

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

Methods included from JSON

dump_json, load_json, safe_load_json

Constructor Details

#initialize(item, redis_pool = nil) ⇒ Strategy

Initialize a new Strategy

Parameters:

  • item (Hash)

    sidekiq job hash

  • redis_pool (ConnectionPool) (defaults to: nil)

    the connection pool instance



28
29
30
31
# File 'lib/sidekiq_unique_jobs/on_conflict/strategy.rb', line 28

def initialize(item, redis_pool = nil)
  @item       = item
  @redis_pool = redis_pool
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



17
18
19
# File 'lib/sidekiq_unique_jobs/on_conflict/strategy.rb', line 17

def item
  @item
end

#redis_poolObject (readonly)

Returns the value of attribute redis_pool.



20
21
22
# File 'lib/sidekiq_unique_jobs/on_conflict/strategy.rb', line 20

def redis_pool
  @redis_pool
end

Instance Method Details

#callObject

Use strategy on conflict

Raises:

  • (NotImplementedError)

    needs to be implemented in child class



35
36
37
# File 'lib/sidekiq_unique_jobs/on_conflict/strategy.rb', line 35

def call
  raise NotImplementedError, "needs to be implemented in child class"
end

#replace?true, false

Check if the strategy is kind of Replace

Returns:

  • (true)

    when the strategy is a Replace

  • (false)

    when the strategy is not a Replace



46
47
48
# File 'lib/sidekiq_unique_jobs/on_conflict/strategy.rb', line 46

def replace?
  is_a?(Replace)
end