JS Task API Reference

Interface: TaskSpecificOptions

executor.TaskSpecificOptions

Table of contents

Properties

Properties

maxParallelTasks

Optional maxParallelTasks: number

Number of maximum parallel running task on one TaskExecutor instance. Default is 5

Defined in

executor.ts:29


taskTimeout

Optional taskTimeout: number

Timeout for execute one task in ms. Default is 300_000 (5 minutes).

Defined in

executor.ts:32


maxTaskRetries

Optional maxTaskRetries: number

The maximum number of retries when the job failed on the provider

Defined in

executor.ts:35


taskStartupTimeout

Optional taskStartupTimeout: number

Timeout for waiting for signing an agreement with an available provider from the moment the task initiated. This parameter is expressed in ms. If it is not possible to sign an agreement within the specified time, the task will stop with an error and will be queued to be retried if the maxTaskRetries parameter > 0

Defined in

executor.ts:43


taskRetryOnTimeout

Optional taskRetryOnTimeout: boolean

Set to false by default. If enabled, timeouts will be retried in case of timeout errors.

Defined in

executor.ts:48


setup

Optional setup: LifecycleFunction

A setup function that will be run when an exe-unit is ready. This is the perfect place to run setup function that need to be run only once per exe-unit, for example uploading files that will be used by all tasks in the exe-unit.

Example

const uploadFile = async (exe) => exe.uploadFile("./file1.txt", "/file1.txt");

const executor = await TaskExecutor.create({
  demand: {
    workload: {
      imageTag: "golem/alpine:latest",
    },
  },
  task: {
    setup: uploadFile,
  }
});

Defined in

executor.ts:71


teardown

Optional teardown: LifecycleFunction

A teardown function that will be run before the exe unit is destroyed. This is the perfect place to run teardown function that need to be run only once per exe-unit at the end of the entire work, for example cleaning of the working environment.

Example

const removeFile = async (exe) => exe.run("rm ./file.txt");

const executor = await TaskExecutor.create({
  demand: {
    workload: {
      imageTag: "golem/alpine:latest",
    },
  },
  task: {
    teardown: removeFile,
  }
});

Defined in

executor.ts:94

Was this helpful?