Module: Zeridion::Flare::Job::ClassMacros

Defined in:
lib/zeridion_flare/worker/job.rb

Overview

flare_options ... and the resolved config readers, mixed into the including class as class methods.

Instance Method Summary collapse

Instance Method Details

#flare_job_typeObject



55
56
57
58
# File 'lib/zeridion_flare/worker/job.rb', line 55

def flare_job_type
  @flare_job_type || name ||
    raise(ArgumentError, "anonymous job class needs an explicit flare_options(job_type:)")
end

#flare_max_attemptsObject



64
65
66
# File 'lib/zeridion_flare/worker/job.rb', line 64

def flare_max_attempts
  @flare_max_attempts || 3
end

#flare_options(job_type: nil, queue: nil, max_attempts: nil, timeout: nil, payload_struct: nil) ⇒ Object

Set per-class defaults. All keys optional.

Parameters:

  • job_type (String, nil) (defaults to: nil)

    explicit routing type (default: class FQN)

  • queue (String) (defaults to: nil)
  • max_attempts (Integer) (defaults to: nil)
  • timeout (Integer) (defaults to: nil)

    seconds

  • payload_struct (Class, nil) (defaults to: nil)

    keyword-initializable payload type



46
47
48
49
50
51
52
53
# File 'lib/zeridion_flare/worker/job.rb', line 46

def flare_options(job_type: nil, queue: nil, max_attempts: nil, timeout: nil, payload_struct: nil)
  @flare_job_type = job_type unless job_type.nil?
  @flare_queue = queue unless queue.nil?
  @flare_max_attempts = max_attempts unless max_attempts.nil?
  @flare_timeout = timeout unless timeout.nil?
  @flare_payload_struct = payload_struct unless payload_struct.nil?
  nil
end

#flare_payload_structObject



72
73
74
# File 'lib/zeridion_flare/worker/job.rb', line 72

def flare_payload_struct
  @flare_payload_struct
end

#flare_queueObject



60
61
62
# File 'lib/zeridion_flare/worker/job.rb', line 60

def flare_queue
  @flare_queue || "default"
end

#flare_timeoutObject



68
69
70
# File 'lib/zeridion_flare/worker/job.rb', line 68

def flare_timeout
  @flare_timeout || 1800
end