Class: Zizq::Resources::Job
- Inherits:
-
JobTemplate
- Object
- Resource
- JobTemplate
- Zizq::Resources::Job
- Defined in:
- lib/zizq/resources/job.rb,
sig/generated/zizq/resources/job.rbs
Overview
Typed wrapper around a job response hash.
Inherits template fields (type, queue, priority, payload, backoff, retention, unique_key, unique_while) from JobTemplate and adds lifecycle fields and action methods.
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #attempts ⇒ Object
-
#complete! ⇒ Object
Mark this job as successfully completed.
- #completed_at ⇒ Object
-
#delete ⇒ void
Delete this job.
- #dequeued_at ⇒ Object
- #duplicate? ⇒ Boolean
-
#errors(order: nil, limit: nil, page_size: nil) ⇒ ErrorEnumerator
Fetch the error history for this job.
-
#fail!(message:, error_type: nil, backtrace: nil, retry_at: nil, kill: false) ⇒ Job
Report this job as failed.
- #failed_at ⇒ Object
- #folded? ⇒ Boolean
- #id ⇒ Object
- #ready_at ⇒ Object
- #status ⇒ Object
-
#update(queue: Zizq::UNCHANGED, priority: Zizq::UNCHANGED, ready_at: Zizq::UNCHANGED, retry_limit: Zizq::UNCHANGED, backoff: Zizq::UNCHANGED, retention: Zizq::UNCHANGED) ⇒ Job
Update this job's mutable fields.
Methods inherited from JobTemplate
#backoff, #batch, #payload, #priority, #queue, #retention, #retry_limit, #type, #unique_key, #unique_while
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
#attempts ⇒ Object
18 |
# File 'lib/zizq/resources/job.rb', line 18 def attempts = @data["attempts"] #: () -> Integer |
#complete! ⇒ Object
Mark this job as successfully completed.
36 37 38 |
# File 'lib/zizq/resources/job.rb', line 36 def complete! #: () -> nil @client.report_success(id) end |
#completed_at ⇒ Object
21 |
# File 'lib/zizq/resources/job.rb', line 21 def completed_at = ms_to_seconds(@data["completed_at"]) #: () -> Float? |
#delete ⇒ void
This method returns an undefined value.
Delete this job.
68 69 70 |
# File 'lib/zizq/resources/job.rb', line 68 def delete @client.delete_job(id) end |
#dequeued_at ⇒ Object
19 |
# File 'lib/zizq/resources/job.rb', line 19 def dequeued_at = ms_to_seconds(@data["dequeued_at"]) #: () -> Float? |
#duplicate? ⇒ Boolean
22 |
# File 'lib/zizq/resources/job.rb', line 22 def duplicate? = @data["duplicate"] == true #: () -> bool |
#errors(order: nil, limit: nil, page_size: nil) ⇒ ErrorEnumerator
Fetch the error history for this job.
31 32 33 |
# File 'lib/zizq/resources/job.rb', line 31 def errors(order: nil, limit: nil, page_size: nil) ErrorEnumerator.new(id, order:, limit:, page_size:) end |
#fail!(message:, error_type: nil, backtrace: nil, retry_at: nil, kill: false) ⇒ Job
Report this job as failed.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/zizq/resources/job.rb', line 48 def fail!( message:, error_type: nil, backtrace: nil, retry_at: nil, kill: false ) @client.report_failure( id, message:, error_type:, backtrace:, retry_at:, kill: ) end |
#failed_at ⇒ Object
20 |
# File 'lib/zizq/resources/job.rb', line 20 def failed_at = ms_to_seconds(@data["failed_at"]) #: () -> Float? |
#folded? ⇒ Boolean
23 |
# File 'lib/zizq/resources/job.rb', line 23 def folded? = @data["folded"] == true #: () -> bool |
#id ⇒ Object
15 |
# File 'lib/zizq/resources/job.rb', line 15 def id = @data["id"] #: () -> String |
#ready_at ⇒ Object
17 |
# File 'lib/zizq/resources/job.rb', line 17 def ready_at = ms_to_seconds(@data["ready_at"]) #: () -> Float? |
#status ⇒ Object
16 |
# File 'lib/zizq/resources/job.rb', line 16 def status = @data["status"] #: () -> String |
#update(queue: Zizq::UNCHANGED, priority: Zizq::UNCHANGED, ready_at: Zizq::UNCHANGED, retry_limit: Zizq::UNCHANGED, backoff: Zizq::UNCHANGED, retention: Zizq::UNCHANGED) ⇒ Job
Update this job's mutable fields.
Returns the updated job.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/zizq/resources/job.rb', line 83 def update( queue: Zizq::UNCHANGED, priority: Zizq::UNCHANGED, ready_at: Zizq::UNCHANGED, retry_limit: Zizq::UNCHANGED, backoff: Zizq::UNCHANGED, retention: Zizq::UNCHANGED ) job = @client.update_job( id, queue:, priority:, ready_at:, retry_limit:, backoff:, retention: ) # Make sure this job's fields are updated. @data.merge!(job.to_h) job end |