KScript docs
EN

queue fields and methods

A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).

Fields

FieldTypeDescription
.connectionstringThe connection the queue is on.
.namestringThe queue's name.

From KScript.Queue

These need <import package="KScript.Queue" />import KScript.Queue. See KScript.Queue.

#queue->batch(id: string) → batch KScript.Queue

A batch dispatched on this connection, as the queue has it now, or null: @queue()->batch($id).progress.
ParameterTakes
id requiredstring
Example
<echo>{ @queue('default', connection: 'memory')->batch('no-such-id') ?? 'none' }</echo>
echo @queue('default', connection: 'memory')->batch('no-such-id') ?? 'none'

#queue->clear(failed?: bool) → number KScript.Queue

Removes every waiting job and returns how many there were. With failed, deletes every failed job of this queue instead, as kscript queue delete --all does.
ParameterTakes
failed optionala flag: failed or not failed
Example
<echo>{ @queue('default', connection: 'memory')->clear() } removed, { @queue('default', connection: 'memory')->clear(failed) } failed deleted</echo>
echo "{ @queue('default', connection: 'memory')->clear() } removed, { @queue('default', connection: 'memory')->clear(failed) } failed deleted"

#queue->failed() → list KScript.Queue

The jobs of this queue that failed: id, job, fields, attempts, failed_at and error.
Example
<echo>{ @queue('default', connection: 'memory')->failed()->count() }</echo>
echo @queue('default', connection: 'memory')->failed()->count()

#queue->remove(id: string) → bool KScript.Queue

Deletes a failed job of this queue for good, as kscript queue delete does. True when there was one with that id.
ParameterTakes
id requiredstring
Example
<echo>{ @queue('default', connection: 'memory')->remove('no-such-id') }</echo>
echo @queue('default', connection: 'memory')->remove('no-such-id')

#queue->retry(id?: string, all?: bool) → bool KScript.Queue

Puts a failed job back on its queue, with its tries reset: true when there was one with that id. With all, puts back every failed job of this queue, as kscript queue retry --all does: true when there was one.
ParameterTakes
id optionalstring
all optionala flag: all or not all

Arguments can be named: ->retry(…, all: …).

Example
<echo>{ @queue('default', connection: 'memory')->retry('no-such-id') } { @queue('default', connection: 'memory')->retry(all) }</echo>
echo "{ @queue('default', connection: 'memory')->retry('no-such-id') } { @queue('default', connection: 'memory')->retry(all) }"

#queue->size() → number KScript.Queue

How many jobs are waiting, including delayed ones.
Example
<echo>{ @queue('default', connection: 'memory')->size() }</echo>
echo @queue('default', connection: 'memory')->size()

#queue->waiting() → list KScript.Queue

The waiting jobs: id, job, queue, fields, attempts, available_at.
Example
<echo>{ @queue('default', connection: 'memory')->waiting()->count() }</echo>
echo @queue('default', connection: 'memory')->waiting()->count()

Methods from any