Module

dcp/compute

Module that implements Compute API

Namespaces

sandboxEnv

Methods

# static cancel(id, ownerKeystore) → {object}

Cancel a running job, by address

Parameters:
Name Type Description
id string

Address of the job to cancel.

ownerKeystore wallet.Keystore

The keystore of the job owner

when id or ownerKeystore are not provided.

The status of the funds that were released from escrow.

object

# static do(n, work, argumentsopt) → {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

Work function as string or function literal.

arguments object <optional>
[]

optional Array-like object which contains arguments which are passed to the work func

Job
Example
let job = compute.do(5, function (i) {
  progress('100%')
  return i*10
})

# static do(work, argumentsopt) → {Job}

Form 1. Create a job which will run a work function once

Parameters:
Name Type Attributes Default Description
work function | string

Work function as string or function literal.

arguments object <optional>
[]

optional Array-like object which contains arguments which are passed to the work func

Job
Example
let job = compute.do(function (i) {
  progress('100%')
  return i*10
})
   

# static for(rangeObject, work, argumentsopt) → {Job}

Form 1. 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

Work function as string or function literal.

arguments object <optional>
[]

optional Array-like object which contains arguments that are passed to the work function

Job
Example
let job = compute.for({start: 10, end: 13, step: 2}, (i) => progress(1) && i)
   

# static for(start, end, stepopt, work, argumentsopt) → {Job}

Form 2. 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

Work function as string or function literal.

arguments object <optional>
[]

optional Array-like object which contains arguments that are passed to the work function

Job
Example
let job = compute.for(1, 3, function (i) {
  progress('100%')
  return i*10
})
   

# static for(multiRange, work, argumentsopt) → {Job}

Form 3. Similar to form1, 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

Work function as string or function literal.

arguments object <optional>
[]

optional Array-like object which contains arguments that are passed to the work function

Job
Example
let job = compute.for([{start: 1, end: 2}, {start: 3, end: 5}], function(i,j) {
  return [i, j, i*j]
})
   

# static for(iterableObject, work, argumentsopt) → {Job}

Form 4. 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

Work function as string or function literal.

arguments object <optional>
[]

optional Array-like object which contains arguments that are passed to the work function

Job
Example
let job = compute.for([123,456], function(i) { 
  progress(1)
  return i
})

# 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.

object

# 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.

object

# static resume(id, ownerKeystoreopt) → {Job}

Reconnect/resume a job, by address

Parameters:
Name Type Attributes Default Description
id string

Address of the Job to resume/reconnect.

ownerKeystore wallet.Keystore <optional>
wallet.get()

The keystore of the job owner

when id is not provided.

Job

# 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.

object

# 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.

object