#job->dispatch(delay?: duration, at?: date, queue?: string(min: 1), connection?: string(min: 1), after_commit?: bool) → map KScript.Queue
Reiht den Job ein und gibt zurück, was eingereiht wurde: { id, job, queue, connection, available_at }. delay (10m) oder at (ein Datum) lassen ihn warten; null, wenn ein eindeutiger Job bereits eingereiht ist. Innerhalb einer Transaktion wird der Job beim Commit eingereiht und bei einem Rollback verworfen; ohne after_commit wird er sofort eingereiht.
| Parameter | Nimmt |
|---|---|
delay optional | Dauer |
at optional | date |
queue optional | string(min: 1) |
connection optional | string(min: 1) |
after_commit optional | ein Flag: after_commit oder not after_commit |
Argumente können benannt werden: ->dispatch(…, at: …, queue: …).
Beispiel
<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