class
Amber::Jobs::Scheduler
- Amber::Jobs::Scheduler
- Reference
- Object
Overview
Handles periodic promotion of scheduled and delayed jobs.
The Scheduler runs in a background fiber and periodically checks the queue adapter for scheduled jobs that are ready to execute. This is primarily useful for adapters that separate scheduled jobs from the immediate queue (like the MemoryQueueAdapter).
In the MemoryQueueAdapter, scheduled job promotion happens during dequeue, so the scheduler serves as an additional check to ensure jobs are promoted even when no dequeue calls are happening.
Usage
scheduler = Amber::Jobs::Scheduler.new(
adapter: adapter,
interval: 5.seconds
)
scheduler.start
Defined in:
amber/jobs/scheduler.crConstant Summary
-
Log =
::Log.for(self)
Constructors
Instance Method Summary
- #adapter : QueueAdapter
- #interval : Time::Span
- #is_running? : Bool
-
#start : Nil
Starts the scheduler in a background fiber.
-
#stop : Nil
Stops the scheduler.
-
#tick : Nil
Performs a single scheduler tick.
Constructor Detail
Instance Method Detail
Starts the scheduler in a background fiber.
The scheduler will periodically trigger dequeue on all configured queues to promote scheduled jobs. This is a no-op if the scheduler is already running.
Stops the scheduler.
The scheduler will finish its current sleep cycle and then stop.
Performs a single scheduler tick.
This is exposed as a public method primarily for testing purposes, allowing specs to trigger scheduler behavior without running in a fiber.