#job->dispatch(delay?: duration, at?: date, queue?: string(min: 1), connection?: string(min: 1), after_commit?: bool) → map KScript.Queue
Queues the job and returns what was queued: { id, job, queue, connection, available_at }. delay (10m) or at (a date) make it wait; null when a unique job is already queued. Inside a transaction the job is queued when it commits, and dropped if it rolls back; not after_commit queues it at once.
| Parameter | Takes |
|---|---|
delay optional | duration |
at optional | date |
queue optional | string(min: 1) |
connection optional | string(min: 1) |
after_commit optional | a flag: after_commit or not after_commit |
Arguments can be named: ->dispatch(…, at: …, queue: …).
Example
<job name="Hello" fields="who: string">
<fn name="handle"><echo>Hello { $who }</echo></fn>
</job>
<do>@fake_queue()</do>
<let name="queued" value="Hello(who: 'Joan')->dispatch(delay: 10m, queue: 'high')" />
<echo>{ $queued.queue }</echo>job Hello {
who: string
fn handle() {
echo "Hello { .who }"
}
}
@fake_queue()
$queued = Hello(who: 'Joan')->dispatch(delay: 10m, queue: 'high')
echo $queued.queue