Module that implements Compute API
Namespaces
Methods
# static cancel(id, ownerKeystore, reason) → {object}
Cancel a running job, by opaque id
Parameters:
Name | Type | Description |
---|---|---|
id |
string | opaqueId of the job to cancel. |
ownerKeystore |
wallet.Keystore | The keystore of the job owner |
reason |
string | If provided, will be sent on to client |
when id or ownerKeystore are not provided.
The status of the funds that were released from escrow.
# static do(work, workFunctionArgsopt) → {Job}
Form 1. Create a job which will run a work function once
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
work |
function | string | URL | DcpURL | Work function as string or function literal. |
||
workFunctionArgs |
object |
<optional> |
[] | optional Array-like object which contains arguments which are passed to the work func |
Example
const job = compute.do(function (i) {
progress('100%')
return i*10
})
# static do(n, work, workFunctionArgsopt) → {Job}
Form 2. Create a job which will run a work function on the values 1..n
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
n |
number | Number of times to run the work function. |
||
work |
function | string | URL | DcpURL | Work function as string or function literal. |
||
workFunctionArgs |
object |
<optional> |
[] | optional Array-like object which contains arguments which are passed to the work func |
Example
const job = compute.do(5, function (i) {
progress('100%')
return i*10
})
# static for(iterableObject, work, argumentsopt) → {Job}
Form 3. Create a Job for the distributed computer by specifying the input as an Iterable object with a given work function and arguments.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
iterableObject |
Iterable | Array, ES6 function* generator, or any other type of iterable object. |
||
work |
function | string | URL | DcpURL | Work function as string or function literal. |
||
arguments |
object |
<optional> |
[] | optional Array-like object which contains arguments that are passed to the work function |
Example
let job = compute.for([123,456], function(i) {
progress(1)
return i
})
# static for(remoteDataSet, work, argumentsopt) → {Job}
Form 2. Create a Job for the distributed computer by specifying the input as a RemoteDataSet with a given work function and arguments.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
remoteDataSet |
RemoteDataSet | Array, ES6 function* generator, or any other type of iterable object. |
||
work |
function | string | URL | DcpURL | Work function as string or function literal. |
||
arguments |
object |
<optional> |
[] | optional Array-like object which contains arguments that are passed to the work function |
Example
const remoteData = ['https://example.com/data'];
const job = compute.for(new RemoteDataSet(...remoteData), function(i) {
progress(1)
return i
})
# static for(start, end, stepopt, work, argumentsopt) → {Job}
Form 1. Create a Job for the distributed computer by specifying the start, end, and step for a RangeObject with a given work function and arguments.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
start |
number | First number in a range (see RangeObject) |
||
end |
number | Last number in a range (see RangeObject) |
||
step |
number |
<optional> |
1 | the space between numbers in a range (see RangeObject) |
work |
function | string | URL | DcpURL | Work function as string or function literal. |
||
arguments |
object |
<optional> |
[] | optional Array-like object which contains arguments that are passed to the work function |
Example
let job = compute.for(1, 3, function (i) {
progress('100%')
return i*10
})
# static for(rangeObject, work, argumentsopt) → {Job}
Form 4. Create a Job for the distributed computer by specifying the input as a RangeObject with a given work function and arguments.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rangeObject |
RangeObject | Either a RangeObject or an object literal which can be used to create a RangeObject (see RangeObject). |
||
work |
function | string | URL | DcpURL | Work function as string or function literal. |
||
arguments |
object |
<optional> |
[] | optional Array-like object which contains arguments that are passed to the work function |
Example
let job = compute.for({start: 10, end: 13, step: 2}, (i) => progress(1) && i)
# static for(multiRange, work, argumentsopt) → {Job}
Form 5. Similar to Form 4, except with a multi range object containing an array of range objects in the key ranges. These are used to create multi-dimensional ranges, like nested loops. If they were written as traditional loops, the outermost loop would be the leftmost range object, and the innermost loop would be the rightmost range object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
multiRange |
MultiRangeObject | Either a MultiRangeObject or any valid argument to the constructor. |
||
work |
function | string | URL | DcpURL | Work function as string or function literal. |
||
arguments |
object |
<optional> |
[] | optional Array-like object which contains arguments that are passed to the work function |
Example
let job = compute.for([{start: 1, end: 2}, {start: 3, end: 5}], function(i,j) {
return [i, j, i*j]
})
# static getJobInfo(jobID) → {object}
Returns information for the job with the provided ID. It will use wallet.get()
to retrieve the auth keystore.
Parameters:
Name | Type | Description |
---|---|---|
jobID |
string | The job ID |
A status object describing a given job.
# static getSliceInfo(jobID) → {object}
Returns information for the slices of the job with the provided ID. It will use wallet.get()
to retrieve the auth keystore.
Parameters:
Name | Type | Description |
---|---|---|
jobID |
string | The job ID |
A slice status object for the given job.
# static resume(id, ownerKeystoreopt) → {Job}
Reconnect/resume a job, by opaque id
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | Opaque id of the Job to resume/reconnect. |
||
ownerKeystore |
wallet.Keystore |
<optional> |
wallet.get() | The keystore of the job owner |
when id is not provided.
# static status(optsopt, ownerKeystore) → {object}
Form 2. Query the status of jobs deployed to the scheduler.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opts |
object |
<optional> |
Query options |
startTime |
number |
<optional> |
Jobs older than this will be excluded from the results. |
endTime |
number |
<optional> |
Jobs newer than this will be excluded from the results. |
ownerKeystore |
wallet.Keystore |
when ownerKeystore is not provided
An array of status objects corresponding to the status of jobs deployed by the given payment account.
# static status(job, ownerKeystore) → {object}
Form 1. Query the status of a job that has been deployed to the scheduler.
Parameters:
Name | Type | Description |
---|---|---|
job |
string | Job | A job ID or a Job instance |
ownerKeystore |
wallet.Keystore |
when ownerKeystore is not provided
A status object describing a given job.