Class: Zizq::Resources::JobTemplate

Inherits:
Resource
  • Object
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

Constructor Details

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

Instance Method Details

#backoffObject

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

Returns:

  • (Object)


30
31
32
33
34
35
36
37
38
39
# File 'lib/zizq/resources/job_template.rb', line 30

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

#batchObject

Batching configuration for this job. Retutns nil for non-batched jobs.

Returns:

  • (Object)


21
22
23
24
25
26
# File 'lib/zizq/resources/job_template.rb', line 21

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

  { key: raw["key"], when: raw["when"], fold: raw["fold"] }
end

#payloadObject

Signature:

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

Returns:

  • (Object)


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

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

#priorityObject

Signature:

  • () -> Integer?

Returns:

  • (Object)


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

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

#queueObject

Signature:

  • () -> String

Returns:

  • (Object)


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

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

#retentionObject

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

Returns:

  • (Object)


43
44
45
46
47
48
49
50
51
# File 'lib/zizq/resources/job_template.rb', line 43

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

Signature:

  • () -> Integer?

Returns:

  • (Object)


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

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

#typeObject

Signature:

  • () -> String

Returns:

  • (Object)


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

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

#unique_keyObject

Signature:

  • () -> String?

Returns:

  • (Object)


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

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

#unique_whileObject

Signature:

  • () -> Zizq::unique_scope?

Returns:

  • (Object)


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

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