Class: Zeridion::Flare::Worker::JobDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/zeridion_flare/worker/job_definition.rb

Overview

Resolved, immutable metadata for one registered job class — the Ruby analog of the reference SDK's JobTypeInfo. Built by the Registry from a job class's flare_options. recurring? distinguishes the two #perform arities (payload vs payloadless).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_type:, job_class:, queue:, max_attempts:, timeout_seconds:, cron: nil, timezone: nil, payload_struct: nil) ⇒ JobDefinition

Returns a new instance of JobDefinition.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/zeridion_flare/worker/job_definition.rb', line 14

def initialize(job_type:, job_class:, queue:, max_attempts:, timeout_seconds:,
               cron: nil, timezone: nil, payload_struct: nil)
  @job_type = job_type
  @job_class = job_class
  @queue = queue
  @max_attempts = max_attempts
  @timeout_seconds = timeout_seconds
  @cron = cron
  @timezone = timezone
  @payload_struct = payload_struct
  freeze
end

Instance Attribute Details

#cronObject (readonly)

Returns the value of attribute cron.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def cron
  @cron
end

#job_classObject (readonly)

Returns the value of attribute job_class.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def job_class
  @job_class
end

#job_typeObject (readonly)

Returns the value of attribute job_type.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def job_type
  @job_type
end

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def max_attempts
  @max_attempts
end

#payload_structObject (readonly)

Returns the value of attribute payload_struct.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def payload_struct
  @payload_struct
end

#queueObject (readonly)

Returns the value of attribute queue.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def queue
  @queue
end

#timeout_secondsObject (readonly)

Returns the value of attribute timeout_seconds.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def timeout_seconds
  @timeout_seconds
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



11
12
13
# File 'lib/zeridion_flare/worker/job_definition.rb', line 11

def timezone
  @timezone
end

Class Method Details

.from_payload_class(klass) ⇒ Object

Build from a class that included Zeridion::Flare::Job.



32
33
34
35
36
37
38
39
40
41
# File 'lib/zeridion_flare/worker/job_definition.rb', line 32

def self.from_payload_class(klass)
  new(
    job_type: klass.flare_job_type,
    job_class: klass,
    queue: klass.flare_queue,
    max_attempts: klass.flare_max_attempts,
    timeout_seconds: klass.flare_timeout,
    payload_struct: klass.flare_payload_struct,
  )
end

.from_recurring_class(klass) ⇒ Object

Build from a class that included Zeridion::Flare::RecurringJob.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/zeridion_flare/worker/job_definition.rb', line 44

def self.from_recurring_class(klass)
  new(
    job_type: klass.flare_job_type,
    job_class: klass,
    queue: klass.flare_queue,
    max_attempts: klass.flare_max_attempts,
    timeout_seconds: klass.flare_timeout,
    cron: klass.flare_cron,
    timezone: klass.flare_timezone,
  )
end

Instance Method Details

#recurring?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/zeridion_flare/worker/job_definition.rb', line 27

def recurring?
  !@cron.nil?
end