Skip to content

Latest commit

 

History

History
372 lines (269 loc) · 13 KB

API.md

File metadata and controls

372 lines (269 loc) · 13 KB

Modules

VulpesClient

Classes

JobEventEmitter

Job class

RemoteConnectorConnector

Remote connector class for connecting Vulpes APIs to clients

Typedefs

GetLatestJobTreeOptions : Object
ServerStatus : Object
VulpesJob : Object

A remote job payload (may not be complete)

VulpesClient

VulpesClient.Worker ⇐ EventEmitter

Client worker

Kind: static class of VulpesClient
Extends: EventEmitter

new Worker(connector)

Constructor for the worker

Param Type Description
connector Connector A connector instance

Job ⇐ EventEmitter

Job class

Kind: global class
Extends: EventEmitter

new Job(jobData)

Constructor for the Job class

Param Type Description
jobData Object The job data, containing the entire job payload

job.data : Object

The job's data

Kind: instance property of Job
Read only: true

job.id : String

The job ID

Kind: instance property of Job
Read only: true

job.jobData : Object

The full job payload reference

Kind: instance property of Job
Read only: true

job.status : String

The current job status

Kind: instance property of Job
Read only: true

job.type : String

The job type

Kind: instance property of Job
Read only: true

job.getTimeLeft() ⇒ Promise.<(Number|Infinity)>

Get the time left to complete the job

Kind: instance method of Job
Returns: Promise.<(Number|Infinity)> - Returns the time left in milliseconds or Infinity if no limit is imposed

job.stop(resultType, [resultData]) ⇒ Promise

Stop the job, setting a result

Kind: instance method of Job

Param Type Description
resultType String The type of result
[resultData] Object Optional result payload

job.updateProgress(current, max) ⇒ Promise

Update the job's progress

Kind: instance method of Job

Param Type Description
current Number The current progress value (must be 0 or greater and less than or equal to max)
max Number The max progress value (must be greater than or equal to current)

Job.ResultType : Object

Job result type

Kind: static property of Job

RemoteConnector ⇐ Connector

Remote connector class for connecting Vulpes APIs to clients

Kind: global class
Extends: Connector

new RemoteConnector(apiURL)

Constructor for a RemoteConnector

Param Type Description
apiURL String The URL root to the Vulpes API (eg: "http://localhost/api/v1")

remoteConnector.apiURL : String

The API URL base

Kind: instance property of RemoteConnector
Read only: true

remoteConnector.getJob(jobID) ⇒ Promise.<VulpesJob>

Get a job for an ID

Kind: instance method of RemoteConnector
Returns: Promise.<VulpesJob> - The job matching the ID

Param Type Description
jobID String The ID of the job

remoteConnector.getJobTree(jobID) ⇒ Promise.<Array.<VulpesJob>>

Get a job tree by a member's ID

Kind: instance method of RemoteConnector
Returns: Promise.<Array.<VulpesJob>> - A promise that resolves with an array of vulpes jobs

Param Type Description
jobID String The job ID to fetch the tree for

remoteConnector.getServiceTime() ⇒ Promise.<Number>

Get the time at the point where the Service is running

Kind: instance method of RemoteConnector
Returns: Promise.<Number> - A promise that resolves with the timestamp of the server

remoteConnector.queryJobs(query, [options]) ⇒ Promise.<Array.<VulpesJob>>

Query the remote service for jobs

Kind: instance method of RemoteConnector
Returns: Promise.<Array.<VulpesJob>> - A promise that resolves with an array of jobs

Param Type Description
query Object The jobs query (refer to Vulpes documentation)
[options] Object Query options

remoteConnector.registerWorker(workerID) ⇒ Promise

Register the worker on the remote service

Kind: instance method of RemoteConnector
Returns: Promise - A promise that resolves once registration is complete

Param Type Description
workerID String The worker's ID (UUID)

remoteConnector.resetJob(jobID) ⇒ Promise

Reset a job with an ID

Kind: instance method of RemoteConnector
Returns: Promise - A promise that resolves once the reset has been completed

Param Type Description
jobID String The job ID

remoteConnector.startJob() ⇒ Promise.<VulpesJob>

Start a job - fetches a job from the server

Kind: instance method of RemoteConnector
Returns: Promise.<VulpesJob> - A promise that resolves with a job to undertake

remoteConnector.stopJob(jobID, resultType, [resultData])

Stop/Complete a job

Kind: instance method of RemoteConnector

Param Type Description
jobID String The job ID
resultType String The result type: ResultType
[resultData] Object The result data

remoteConnector.updateProgress(jobID, currentValue, maxValue)

Update job progress

Kind: instance method of RemoteConnector

Param Type Description
jobID String The ID of the job to update progress for
currentValue Number The current progress value
maxValue Number The maximum progress value

remoteConnector._getStatus() ⇒ Promise.<ServerStatus>

Fetch the current system status

Kind: instance method of RemoteConnector
Returns: Promise.<ServerStatus> - A promise that resolves with the server state

remoteConnector.getLatestJobTree(dataQuery, [options]) ⇒ Promise.<Array.<VulpesJob>>

Get the latest job tree for some criteria

Kind: instance method of RemoteConnector
Returns: Promise.<Array.<VulpesJob>> - A promise that resolves with an array of vulpes jobs

Param Type Description
dataQuery Object Query item for quering job data (from 'data' onwards)
[options] GetLatestJobTreeOptions Fetch options

GetLatestJobTreeOptions : Object

Kind: global typedef
Properties

Name Type Description
[useResult] Boolean Whether to use result data or initialisation data. Default is false (initialisation data).

ServerStatus : Object

Kind: global typedef
Properties

Name Type Description
status String The status of the server (ok/offline/init)
api String The server version
started Number UTC timestamp of when the server was started

VulpesJob : Object

A remote job payload (may not be complete)

Kind: global typedef
Properties

Name Type Description
id String The job ID
type String The job type
status String The job status (pending etc.): Status
priority String The priority of the job: Priority
created Number The creation timestamp (UTC)
parents Array.<String> Array of parent IDs
data Object The job data (initialisation)
result Object The results of the job's previous execution
result.type String The type of result: ResultType
result.data Object The result data