JSMA job

Overview

The JSMA job provides access to an individual background job.

Index

Methods

The JSMA job provides the following methods:

int job.id

Returns the job's database ID

Example

...
var id = job.id # => 1
...

string job.status

Returns the job's status field

Example

...
var status = job.status; # => 'done'
...

object job.data

Returns the job's data object

Example

...
var data = job.data; # => { some: 'arguments', ... }
...

array job.log

Returns the job's log array in chronological order.

Example

...
var log = job.log; # => [{"type"=>"success", "message"=>"{\"status\": \"OK\"}", "time"=>"2018-09-21 13:48:17 +0200"}, ...]
...

void job.retry()

Resets the job status and tries. The job will be scheduled for retry. The log persists.

Example

...
job.retry()
...

void job.cancel()

Cancels the job if it is scheduled to run.

Example

...
job.cancel()
...

void job.update(data)

Updates the job's data object.

Example

...
job.update(JSON.stringify({ foo: 'bar' }));
...

Parameter data:string (required)

An arbitrary object serialized to JSON.

void job.setError(message)

Sets the state of the job to 'error'. If there are tries left for this job it will be scheduled for retrying according to the 'wait' setting of the job profile.

Example

...
job.setError('some error occurred');
...

Parameter message:string (required)

The error message that will be logged.

void job.setFatal(message)

Sets the state of the job to 'fatal'. No further retries will be made.

Example

...
job.setFatal('some fatal error');
...

Parameter message:string (required)

The error message that will be logged.

void job.setExecutionState(state)

Sets the executionState value of the job to 'fatal'. No further retries will be made.

Example

...
job.setExecutionState(1);
...

Parameter state:int (required)

The integer to be set as executionState.