Class: Job<Output>
This API is experimental and subject to change. Use at your own risk.
The Job class represents a single self-contained unit of work that can be run on the Golem Network. It is responsible for managing the lifecycle of the work and providing information about its state. It also provides an event emitter that can be used to listen for state changes.
Type parameters
Name | Type |
---|---|
Output | unknown |
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new Job<Output
>(id
, glm
, order
, logger
): Job
<Output
>
Type parameters
Name | Type |
---|---|
Output | unknown |
Parameters
Name | Type |
---|---|
id | string |
glm | GolemNetwork |
order | MarketOrderSpec |
logger | Logger |
Returns
Job
<Output
>
Defined in
src/experimental/job/job.ts:76
Properties
events
• Readonly
events: EventEmitter
<JobEventsDict
, any
>
Defined in
src/experimental/job/job.ts:63
results
• results: undefined
| Output
Defined in
src/experimental/job/job.ts:66
error
• error: undefined
| Error
Defined in
src/experimental/job/job.ts:67
state
• state: JobState
= JobState.New
Defined in
src/experimental/job/job.ts:68
id
• Readonly
id: string
Defined in
src/experimental/job/job.ts:77
Methods
isRunning
▸ isRunning(): boolean
Returns
boolean
Defined in
src/experimental/job/job.ts:83
startWork
▸ startWork(workOnGolem
): void
Run your worker function on the Golem Network. This method will synchronously initialize all internal services and validate the job options. The work itself will be run asynchronously in the background. You can use the experimental/job/job.Job.events event emitter to listen for state changes. You can also use experimental/job/job.Job.waitForResult to wait for the job to finish and get the results. If you want to cancel the job, use experimental/job/job.Job.cancel. If you want to run multiple jobs in parallel, you can use experimental/job/job_manager.JobManager.createJob to create multiple jobs and run them in parallel.
Parameters
Name | Type | Description |
---|---|---|
workOnGolem | WorkFunction <Output > | Your worker function that will be run on the Golem Network. |
Returns
void
Defined in
src/experimental/job/job.ts:98
cancel
▸ cancel(): Promise
<void
>
Cancel the job. This method will stop the activity and wait for it to finish. Throws an error if the job is not running.
Returns
Promise
<void
>
Defined in
src/experimental/job/job.ts:161
waitForResult
▸ waitForResult(): Promise
<unknown
>
Wait for the job to finish and return the results. Throws an error if the job was not started.
Returns
Promise
<unknown
>