Module: Wurk::Job::Options::ClassMethods

Defined in:
lib/wurk/job/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sidekiq_retries_exhausted_blockObject (readonly)

Returns the value of attribute sidekiq_retries_exhausted_block.



45
46
47
# File 'lib/wurk/job/options.rb', line 45

def sidekiq_retries_exhausted_block
  @sidekiq_retries_exhausted_block
end

#sidekiq_retry_in_blockObject (readonly)

Returns the value of attribute sidekiq_retry_in_block.



45
46
47
# File 'lib/wurk/job/options.rb', line 45

def sidekiq_retry_in_block
  @sidekiq_retry_in_block
end

Instance Method Details

#get_sidekiq_optionsObject

Sidekiq's public API name — must stay get_sidekiq_options.



37
38
39
# File 'lib/wurk/job/options.rb', line 37

def get_sidekiq_options # rubocop:disable Naming/AccessorMethodName
  @sidekiq_options_hash ||= inherited_sidekiq_options # rubocop:disable Naming/MemoizedInstanceVariableName
end

#inherited(subclass) ⇒ Object



55
56
57
58
59
60
# File 'lib/wurk/job/options.rb', line 55

def inherited(subclass)
  super
  subclass.instance_variable_set(:@sidekiq_options_hash, get_sidekiq_options.dup)
  inherit_ivar(subclass, :@sidekiq_retry_in_block)
  inherit_ivar(subclass, :@sidekiq_retries_exhausted_block)
end

#sidekiq_options(opts = {}) ⇒ Object

Deliberately identical to Wurk::Worker::ClassMethods#sidekiq_options, validation included: an ActiveJob class configuring a Wurk option must be told about a bad value at the same place a plain worker is.



27
28
29
30
31
32
33
34
# File 'lib/wurk/job/options.rb', line 27

def sidekiq_options(opts = {})
  stringified = opts.transform_keys(&:to_s)
  Wurk::JobUtil.validate_track!(stringified['track'], stringified) if stringified.key?('track')
  Wurk::JobUtil.validate_bounds!(stringified)
  merged = get_sidekiq_options.merge(stringified)
  Wurk::Collapse.policy_for(merged)
  @sidekiq_options_hash = merged
end

#sidekiq_options_hashObject



41
42
43
# File 'lib/wurk/job/options.rb', line 41

def sidekiq_options_hash
  get_sidekiq_options
end

#sidekiq_retries_exhausted(&block) ⇒ Object



51
52
53
# File 'lib/wurk/job/options.rb', line 51

def sidekiq_retries_exhausted(&block)
  @sidekiq_retries_exhausted_block = block
end

#sidekiq_retry_in(&block) ⇒ Object



47
48
49
# File 'lib/wurk/job/options.rb', line 47

def sidekiq_retry_in(&block)
  @sidekiq_retry_in_block = block
end