struct Amber::Jobs::JobEnvelope

Overview

Wraps a job with metadata for queue management.

A JobEnvelope carries all the information needed to track, schedule, retry, and execute a job within the background processing system. It acts as the transport container that moves through the queue adapter, worker, and scheduler.

Fields

Included Modules

Defined in:

amber/jobs/job_envelope.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(job_class : String, payload : String, queue : String = "default", max_retries : Int32 = 3, scheduled_at : Time = Time.utc, status : Status = Status::Pending) #

[View source]
def self.new(pull : JSON::PullParser) #

[View source]

Instance Method Detail

def attempts : Int32 #

[View source]
def attempts=(attempts : Int32) #

[View source]
def created_at : Time #

[View source]
def created_at=(created_at : Time) #

[View source]
def has_exceeded_max_retries? : Bool #

Returns true if the job has exceeded its maximum retry attempts.


[View source]
def id : String #

[View source]
def id=(id : String) #

[View source]
def is_ready_to_run? : Bool #

Returns true if the job is ready to be executed based on its scheduled time.


[View source]
def job_class : String #

[View source]
def job_class=(job_class : String) #

[View source]
def last_error : String | Nil #

[View source]
def last_error=(last_error : String | Nil) #

[View source]
def mark_as_completed : Nil #

Sets the status to Completed.


[View source]
def mark_as_dead(error : String) : Nil #

Sets the status to Dead (exceeded max retries, will not be retried).


[View source]
def mark_as_failed(error : String) : Nil #

Sets the status to Failed with an error message.


[View source]
def mark_as_running : Nil #

Increments the attempt counter and sets the status to Running.


[View source]
def max_retries : Int32 #

[View source]
def max_retries=(max_retries : Int32) #

[View source]
def payload : String #

[View source]
def payload=(payload : String) #

[View source]
def queue : String #

[View source]
def queue=(queue : String) #

[View source]
def schedule_retry(backoff : Time::Span) : Nil #

Resets the status to Pending for retry, updating the scheduled time based on exponential backoff.


[View source]
def scheduled_at : Time #

[View source]
def scheduled_at=(scheduled_at : Time) #

[View source]
def status : Status #

[View source]
def status=(status : Status) #

[View source]