Class: Zizq::Resources::JobTemplate

Inherits:
Resource
  • Object
show all
Defined in:
lib/zizq/resources/job_template.rb

Overview

Typed wrapper around a job template — the fields shared between live jobs and cron entry job definitions.

Direct Known Subclasses

Job

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize, #inspect, #to_h

Constructor Details

This class inherits a constructor from Zizq::Resources::Resource

Instance Method Details

#backoffObject

Backoff configuration converted from the wire format (ms) to the Ruby-idiomatic format (seconds), matching the Zizq::backoff type.



22
23
24
25
26
27
28
29
30
31
# File 'lib/zizq/resources/job_template.rb', line 22

def backoff #: () -> Zizq::backoff?
  raw = @data["backoff"]
  return nil unless raw

  {
    exponent: raw["exponent"].to_f,
    base: raw["base_ms"] / 1000.0,
    jitter: raw["jitter_ms"] / 1000.0
  }
end

#payloadObject

: () -> Hash[String, untyped]?



15
# File 'lib/zizq/resources/job_template.rb', line 15

def payload      = @data["payload"]      #: () -> Hash[String, untyped]?

#priorityObject

: () -> Integer?



14
# File 'lib/zizq/resources/job_template.rb', line 14

def priority     = @data["priority"]     #: () -> Integer?

#queueObject

: () -> String



13
# File 'lib/zizq/resources/job_template.rb', line 13

def queue        = @data["queue"]        #: () -> String

#retentionObject

Retention configuration converted from the wire format (ms) to the Ruby-idiomatic format (seconds), matching the Zizq::retention type.



35
36
37
38
39
40
41
42
43
# File 'lib/zizq/resources/job_template.rb', line 35

def retention #: () -> Zizq::retention?
  raw = @data["retention"]
  return nil unless raw

  result = {} #: Hash[Symbol, Float]
  result[:completed] = raw["completed_ms"] / 1000.0 if raw["completed_ms"]
  result[:dead] = raw["dead_ms"] / 1000.0 if raw["dead_ms"]
  result
end

#retry_limitObject

: () -> Integer?



16
# File 'lib/zizq/resources/job_template.rb', line 16

def retry_limit  = @data["retry_limit"]  #: () -> Integer?

#typeObject

: () -> String



12
# File 'lib/zizq/resources/job_template.rb', line 12

def type         = @data["type"]         #: () -> String

#unique_keyObject

: () -> String?



17
# File 'lib/zizq/resources/job_template.rb', line 17

def unique_key   = @data["unique_key"]   #: () -> String?

#unique_whileObject

: () -> Zizq::unique_scope?



18
# File 'lib/zizq/resources/job_template.rb', line 18

def unique_while = @data["unique_while"]&.to_sym #: () -> Zizq::unique_scope?