Home Manual Reference Source Repository
public class | source

Job

Extends:

events~EventEmitter → Job

The Job class is used for job operations.

Constructor Summary

Public Constructor
public

constructor(client: Client, jobId: number, progressCallback: function(info: JobProgressInfo), startedCallback: function(info: JobStartedInfo))

Member Summary

Public Members
public

The job Id.

Method Summary

Public Methods
public

cancel(force: boolean): Promise<true, error>

Cancels the job.

public

info(): Promise<JobInfo, error>

Retrieves the job information.

public

wait(): Promise<JobResults, error>

Waits for the job to complete.

Public Constructors

public constructor(client: Client, jobId: number, progressCallback: function(info: JobProgressInfo), startedCallback: function(info: JobStartedInfo)) source

Params:

NameTypeAttributeDescription
client Client

The GSF Client object.

jobId number

The jobId.

progressCallback function(info: JobProgressInfo)
  • optional

The callback to handle job progress.

startedCallback function(info: JobStartedInfo)
  • optional

The callback that is called when the job starts. For more reliable job started information, listen to the GSF JobStarted events as this callback may not always get called. In some cases the job can start before the callback is registered.

Emit:

JobFailed

JobSucceeded

JobCompleted

JobStarted

JobAccepted

JobProgress

Public Members

public jobId: number source

The job Id.

Public Methods

public cancel(force: boolean): Promise<true, error> source

Cancels the job.

Params:

NameTypeAttributeDescription
force boolean

If true, the job will force cancel. Please note that setting force to true may be unsafe depending on the type of job as it may not be able to properly shut down or clean up.

Return:

Promise<true, error>

Returns a promise when cancel is submitted. If request is successfully submitted, the promise will be resolved with a value of true. If the request fails, the promise will be resolved with an error message. Note that this only represents the success of the request made to the server, not the cancellation itself. Use the Job.Info() function (or Job events) to retrieve the status of the job and to learn when it is actually cancelled.

public info(): Promise<JobInfo, error> source

Retrieves the job information.

Return:

Promise<JobInfo, error>

Returns a promise to a JobInfo object.

public wait(): Promise<JobResults, error> source

Waits for the job to complete.

Return:

Promise<JobResults, error>

Returns a promise that is resolved when a job is successful, returning the job results object. If a job fails, the promise is rejected with an error message.