#job->dispatch(delay?: duration, at?: date, queue?: string(min: 1), connection?: string(min: 1), after_commit?: bool) → map KScript.Queue
작업을 큐에 넣고 큐에 넣은 내용을 돌려줘요: { id, job, queue, connection, available_at }. delay(10m)나 at(날짜)을 주면 그때까지 기다려요. 같은 고유 작업이 이미 큐에 있으면 null을 돌려줘요. 트랜잭션 안에서는 커밋될 때 큐에 넣고, 롤백되면 버려요. not after_commit이면 바로 큐에 넣어요.
| 매개변수 | 받는 값 |
|---|---|
delay 선택 | duration |
at 선택 | date |
queue 선택 | string(min: 1) |
connection 선택 | string(min: 1) |
after_commit 선택 | 플래그: after_commit 또는 not after_commit |
인수에는 이름을 붙일 수 있습니다: ->dispatch(…, at: …, queue: …).
예시
<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