Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Jobs

Methods to follow and cancel jobs.

Methods that can take a long time run as jobs (see Request::IS_JOB): they answer right away with a JobStarted, and run in order with the rest of the session’s requests. Their state is sent to clients in JOB_UPDATED_NOTIFICATION notifications, and can be checked or waited for with the methods here, which answer without waiting for other requests.

job.status

Returns the state of a job.

Params (GetJobStatus)

NameTypeRequiredDescription
jobintegeryesID of the job.

Result (JobStatus)

NameTypeRequiredDescription
jobintegeryesID of the job.
methodstringyesMethod the job runs.

Plus one of:

  • { "state": "queued" }: Waiting for the requests before it to finish.
  • { "state": "running", "progress"?: …, "stage"?: … }: Running.
    • progress (integer or null, no): How far along the job is, from 0 to 100, if it reports it.
    • stage (string or null, no): Step the job is on, if it reports them.
  • { "state": "finished", "result": … }: Finished, with the response of its method.
    • result (any, yes): Response of the job’s method.
  • { "state": "failed", "error": … }: Failed, with the error of its method.
    • error (RpcError, yes): Why the job failed.
  • { "state": "cancelled" }: Cancelled before it started.

job.wait

Waits for a job to end, and returns its state.

Params (WaitForJob)

NameTypeRequiredDescription
jobintegeryesID of the job.
timeout_secsinteger or nullnoMaximum amount of seconds to wait. If the job hasn’t ended by then, its current state is returned. Defaults to 60.

Result (JobStatus)

NameTypeRequiredDescription
jobintegeryesID of the job.
methodstringyesMethod the job runs.

Plus one of:

  • { "state": "queued" }: Waiting for the requests before it to finish.
  • { "state": "running", "progress"?: …, "stage"?: … }: Running.
    • progress (integer or null, no): How far along the job is, from 0 to 100, if it reports it.
    • stage (string or null, no): Step the job is on, if it reports them.
  • { "state": "finished", "result": … }: Finished, with the response of its method.
    • result (any, yes): Response of the job’s method.
  • { "state": "failed", "error": … }: Failed, with the error of its method.
    • error (RpcError, yes): Why the job failed.
  • { "state": "cancelled" }: Cancelled before it started.

job.cancel

Cancels a job that hasn’t started yet. Running jobs can’t be cancelled.

Params (CancelJob)

NameTypeRequiredDescription
jobintegeryesID of the job.

Result (Done)

Empty object: {}.

Types

Type RpcError

A JSON-RPC error.

NameTypeRequiredDescription
codeintegeryesNumeric code of the error. See ApiError::code.
messagestringyesHuman-readable description of the error.
dataanynoThe ApiError this was built from, serialized, so clients can match on it.