Module

dcp/compute-groups

Client facing module that implements Compute Groups API

Author:

Methods

# static addJob(computeGroupId, job, joinKey, joinSecret)

Async function that adds a job to a specified compute group. Both Compute Group ID and Job ID must be specified as number Must be the owner of the Compute Group to add a Job to it. The joinKey and the joinSecret (user/password) must also be provided.

Parameters:
Name Type Description
computeGroupId number

the ID of the Compute Group where the job will be added. Analogous to row ID in table.

job opaqueId

the opaque id of the Job that will be added to the Compute Group.

joinKey string

the joinKey for the compute group.

joinSecret string

the joinSecret for the compute group.

Example
await computeGroup.addJob(computeGroupId = 456, job = 'P+Y4IApeFQLrYS2W7MkVg7');

# static cancelAllJobs(computeGroupId)

Async function that cancel all jobs.

Parameters:
Name Type Description
computeGroupId id

the ID of the Compute Group.

Example
await computeGroup.cancelAllJobs(computeGroupId = 123456);

# static cancelJob(computeGroupId, job)

Async function that cancel the specified job.

Parameters:
Name Type Description
computeGroupId id

the ID of the Compute Group.

job opaqueid

the opaque id of the job that will be cancelled.

Example
await computeGroup.cancelJob(computeGroupId = 123456, job = 'P+Y4IApeFQLrYS2W7MkVg7');

# static changeGroup(id, prototype)

Function that changes the properties of an existing Compute Group. The id (computeGroupId, this will be changed later) must be specified as a number. Must be the owner of the Compute Group to change its properties. The joinSecret is entered as a string and stored as an ethutil hash with 'eh1-' appended to the beginning, indicating an ethereum hash.

Changing joinKey and joinSecret will always happen in tandem, since joinKey is seed for joinSecret Ethereum hash. The joinSecret hash is calculated here on the client side - microservice assumes data is good.

Parameters:
Name Type Description
id string

the of of the Compute Group.

prototype object

the object that contains the list of properties to change. This is name, description, joinKey, joinSecret, joinAddress

name string

the name of the Compute Group.

description string

the description of the Compute Group.

joinKey string

the joinKey for joining the Compute Group. Analogous to username.

joinSecret string

the joinSecret for joining the Compute Group. Analogous to password

joinAddress string

the joinAddress of the Compute Group.

Example
await computeGroup.changeGroup( id = 234, {name = 'new name', description = 'new description', joinKey = 'string', joinSecret = 'another string', joinAddress = 'ethAddress'} );

# static create(name, optionsopt) → {Promise.<number>}

Creates a Compute Group, optionally specifying certain aspects of it.

Parameters:
Name Type Attributes Description
name string

The name of the compute group

options object <optional>

Additional properties to specify

description string <optional>

Description of the compute group. Is auto-populated based on name and creation date if not specified.

joinKey string <optional>

A "username" for the compute group. Must be unique and can be specified without a joinSecret.

joinSecret string <optional>

A "password" for the compute group. Must be specified alongside a joinKey.

The id of the compute group that was just created

Promise.<number>
Example
const groupId = await computeGroup.create('myGroup', {
  description: 'This compute group is computing for...!'
  joinKey: '...',
  joinSecret: '...',
});

# static deleteGroup(computeGroupId)

Async function that deletes a Compute Group from the database. The Compute Group ID must be specified as a number. Must be the owner of the Compute Group to delete it.

Parameters:
Name Type Description
computeGroupId id

the ID of the Compute Group that is to be deleted. Analogous to row ID in table.

Example
await computeGroup.deleteGroup(456);

# static listJobs(computeGroupId) → {Array}

Async function that lists all the current Jobs in a Compute Group. The Compute Group ID must be specified. Must be of type number. Must be the owner of the Compute Group to list its current Jobs.

Parameters:
Name Type Description
computeGroupId id

the ID of the Compute Group from which we will list its jobs.

  • the array of Jobs belonging to the computeGroup.
Array
Example
let listOfJobs = await computeGroup.listJobs(computeGroupId = 456);

# static removeJob(computeGroupId, job)

Async function that removes a Compute Group from the the computeGroups table in the scheduler_dcp mysql database. Both Compute Group ID and Job ID must be specified to remove Job from the group. Both of type number. Must be the owner of the Compute Group to remove a Job from it.

Parameters:
Name Type Description
computeGroupId id

the ID of the Compute Group where the job will be removed. Analogous to row ID in table.

job opaqueid

the opaque id of the Job that will be removed from the Compute Group.

Example
await computeGroup.removeJob(computeGroupId = 123456, job = 'P+Y4IApeFQLrYS2W7MkVg7');