module
Amber::Jobs
Defined in:
amber/jobs.cramber/jobs/configuration.cr
amber/jobs/job.cr
amber/jobs/job_envelope.cr
amber/jobs/memory_queue_adapter.cr
amber/jobs/queue_adapter.cr
amber/jobs/scheduler.cr
amber/jobs/worker.cr
Constant Summary
-
Log =
::Log.for(self)
Class Method Summary
-
.adapter : QueueAdapter
Returns the current queue adapter, creating a default MemoryQueueAdapter if none is set.
-
.adapter=(adapter : QueueAdapter)
Sets the queue adapter instance directly.
-
.configuration : Configuration
Returns the current configuration, creating a default if none exists.
-
.configuration=(config : Configuration)
Sets the configuration directly.
-
.configure(&)
Yields the configuration for modification.
-
.deserialize(class_name : String, payload : String) : Job | Nil
Deserializes a job from its class name and JSON payload.
-
.register_job(class_name : String, &block : String -> Job)
Registers a job class with a deserialization proc.
-
.register_retry_backoff(class_name : String, &block : Int32 -> Time::Span)
Registers the retry policy for a job class.
-
.reset : Nil
Resets the jobs system state.
-
.retry_backoff(class_name : String, attempt : Int32) : Time::Span
Returns a registered job's retry delay, or Amber's exponential default when an older/manual registry entry did not register a policy.
-
.start : Nil
Starts the background jobs system.
-
.stop : Nil
Stops all workers and the scheduler.
Macro Summary
-
register(job_class)
Registers a job class for deserialization.
Class Method Detail
Returns the current queue adapter, creating a default MemoryQueueAdapter if none is set.
Returns the current configuration, creating a default if none exists.
Deserializes a job from its class name and JSON payload. Returns nil if the job class is not registered.
Registers a job class with a deserialization proc.
This is the runtime method called by the register macro.
Registers the retry policy for a job class. This is called by register.
Returns a registered job's retry delay, or Amber's exponential default when an older/manual registry entry did not register a policy.
Starts the background jobs system.
Spawns the configured number of workers and starts the scheduler.
This is typically called automatically when the Amber server starts
if is_auto_start_enabled is true in the configuration.
Macro Detail
Registers a job class for deserialization.
This must be called for each job class so the worker can reconstruct the job instance from its serialized JSON payload.
Usage
Amber::Jobs.register(MyJob)