Class: Zizq::Resources::JobTemplate
- Inherits:
-
Resource
- Object
- Resource
- Zizq::Resources::JobTemplate
show all
- Defined in:
- lib/zizq/resources/job_template.rb,
sig/generated/zizq/resources/job_template.rbs
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, #ms_to_seconds, #to_h
Instance Method Details
#backoff ⇒ Object
Backoff configuration converted from the API format (ms) to the
Ruby-idiomatic format (seconds), matching the Zizq::backoff type.
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/zizq/resources/job_template.rb', line 30
def 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
|
#batch ⇒ Object
Batching configuration for this job. Retutns nil for non-batched jobs.
21
22
23
24
25
26
|
# File 'lib/zizq/resources/job_template.rb', line 21
def batch raw = @data["batch"]
return nil unless raw
{ key: raw["key"], when: raw["when"], fold: raw["fold"] }
end
|
#payload ⇒ Object
15
|
# File 'lib/zizq/resources/job_template.rb', line 15
def payload = @data["payload"]
|
#priority ⇒ Object
14
|
# File 'lib/zizq/resources/job_template.rb', line 14
def priority = @data["priority"]
|
#queue ⇒ Object
13
|
# File 'lib/zizq/resources/job_template.rb', line 13
def queue = @data["queue"]
|
#retention ⇒ Object
Retention configuration converted from the API format (ms) to the
Ruby-idiomatic format (seconds), matching the Zizq::retention type.
43
44
45
46
47
48
49
50
51
|
# File 'lib/zizq/resources/job_template.rb', line 43
def retention raw = @data["retention"]
return nil unless raw
result = {} 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_limit ⇒ Object
16
|
# File 'lib/zizq/resources/job_template.rb', line 16
def retry_limit = @data["retry_limit"]
|
#type ⇒ Object
12
|
# File 'lib/zizq/resources/job_template.rb', line 12
def type = @data["type"]
|
#unique_key ⇒ Object
17
|
# File 'lib/zizq/resources/job_template.rb', line 17
def unique_key = @data["unique_key"]
|
#unique_while ⇒ Object
18
|
# File 'lib/zizq/resources/job_template.rb', line 18
def unique_while = @data["unique_while"]&.to_sym
|