Class: TaskExecutor
executor.TaskExecutor
A high-level module for defining and executing tasks in the golem network
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new TaskExecutor(options
)
Create a new TaskExecutor object.
Parameters
Name | Type | Description |
---|---|---|
options | TaskExecutorOptions | TaskExecutorOptions |
Defined in
Properties
events
• Readonly
events: EventEmitter
<ExecutorEvents
, any
>
Defined in
glm
• Readonly
glm: GolemNetwork
This object is the main entry-point to the basic golem-js api. Allows you to listen to events from core golem-js modules such as market, payment, etc. Provides full access to the low-level api intended for more advanced users
Defined in
Methods
create
▸ Static
create(options
): Promise
<TaskExecutor
>
Create a new Task Executor
Parameters
Name | Type | Description |
---|---|---|
options | TaskExecutorOptions | Task executor options |
Returns
Promise
<TaskExecutor
>
TaskExecutor
Description
Factory Method that create and initialize an instance of the TaskExecutor
Example
**Simple usage of Task Executor**
The executor can be created by passing appropriate initial parameters such as market, payment, payment etc.
Example
Usage of Task Executor with custom parameters
const executor = await TaskExecutor.create({
logger: pinoPrettyLogger({ level: "info" }),
demand: {
workload: {
imageTag: "golem/alpine:latest",
},
},
market: {
rentHours: 0.5,
pricing: {
model: "linear",
maxStartPrice: 0.5,
maxCpuPerHourPrice: 1.0,
maxEnvPerHourPrice: 0.5,
},
},
});
Defined in
init
▸ init(): Promise
<void
>
Initialize executor Method responsible for connecting to the golem network and initiating all required services.
Returns
Promise
<void
>
Defined in
shutdown
▸ shutdown(): Promise
<void
>
Stop all executor services and shut down executor instance.
You can call this method multiple times, it will resolve only once the executor is shutdown.
When shutdown() is initially called, a beforeEnd event is emitted.
Once the executor is fully stopped, an end event is emitted.
Returns
Promise
<void
>
Defined in
getStats
▸ getStats(): Object
Returns
Object
Name | Type |
---|---|
retries | undefined | number |
providers | number |
agreements | number |
invoicesReceived | number |
invoicesPaid | number |
invoicesUnpaid | number |
invoicesMissing | number |
invoicePaymentRate | number |
Defined in
run
▸ run<OutputType
>(taskFunction
, options?
): Promise
<OutputType
>
Run task - allows to execute a single taskFunction function on the Golem network with a single provider.
Type parameters
Name |
---|
OutputType |
Parameters
Name | Type | Description |
---|---|---|
taskFunction | TaskFunction <OutputType > | function that run task |
options? | TaskOptions | task options |
Returns
Promise
<OutputType
>
result of task computation
Example
await executor.run(async (exe) => console.log((await exe.run("echo 'Hello World'")).stdout));
Defined in
cancel
▸ cancel(reason
): Promise
<void
>
Parameters
Name | Type |
---|---|
reason | string |
Returns
Promise
<void
>
Defined in
Was this helpful?