Class: Zeridion::Flare::Worker::RecurringSchedule

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

Overview

One cron schedule announced at register time. This is the single typed wire DTO in the worker — everything else stays loose string-keyed Hashes.

The full 6-field shape from the frozen protocol, including timezone (absence ⇒ server-default TZ, which runs non-UTC crons at the wrong local time). #to_wire drops nil fields — Ruby's JSON.generate emits null for nil values, and the server treats a present-but-null field differently from an omitted one, so compaction is load-bearing.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cron_expressionObject (readonly)

Returns the value of attribute cron_expression

Returns:

  • (Object)

    the current value of cron_expression



14
15
16
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 14

def cron_expression
  @cron_expression
end

#job_typeObject (readonly)

Returns the value of attribute job_type

Returns:

  • (Object)

    the current value of job_type



14
15
16
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 14

def job_type
  @job_type
end

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts

Returns:

  • (Object)

    the current value of max_attempts



14
15
16
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 14

def max_attempts
  @max_attempts
end

#queueObject (readonly)

Returns the value of attribute queue

Returns:

  • (Object)

    the current value of queue



14
15
16
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 14

def queue
  @queue
end

#timeout_secondsObject (readonly)

Returns the value of attribute timeout_seconds

Returns:

  • (Object)

    the current value of timeout_seconds



14
15
16
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 14

def timeout_seconds
  @timeout_seconds
end

#timezoneObject (readonly)

Returns the value of attribute timezone

Returns:

  • (Object)

    the current value of timezone



14
15
16
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 14

def timezone
  @timezone
end

Class Method Details

.from_definition(definition) ⇒ Object

Build from a JobDefinition. queue/timezone/max_attempts/timeout_seconds are always populated from the definition's resolved options, so they are sent; only genuinely-absent optionals would be nil.



25
26
27
28
29
30
31
32
33
34
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 25

def self.from_definition(definition)
  new(
    job_type: definition.job_type,
    cron_expression: definition.cron,
    queue: definition.queue,
    timezone: definition.timezone,
    max_attempts: definition.max_attempts,
    timeout_seconds: definition.timeout_seconds,
  )
end

Instance Method Details

#to_wireObject

Snake-case Hash with nil fields removed (so JSON.generate never emits "queue": null etc.).



38
39
40
41
42
43
44
45
46
47
# File 'lib/zeridion_flare/worker/recurring_schedule.rb', line 38

def to_wire
  {
    "job_type" => job_type,
    "cron_expression" => cron_expression,
    "queue" => queue,
    "timezone" => timezone,
    "max_attempts" => max_attempts,
    "timeout_seconds" => timeout_seconds,
  }.compact
end