Skip to main content

@terascope/job-components / execution-context/worker / WorkerExecutionContext

Class: WorkerExecutionContext

Defined in: packages/job-components/src/execution-context/worker.ts:20

WorkerExecutionContext is designed to add more functionality to interface with the Execution Configuration and any Operation.

Extends

Implements

Constructors

new WorkerExecutionContext()

new WorkerExecutionContext(config): WorkerExecutionContext

Defined in: packages/job-components/src/execution-context/worker.ts:33

Parameters

ParameterType
configExecutionContextConfig

Returns

WorkerExecutionContext

Overrides

default.constructor

Properties

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
_loaderreadonlyOperationLoaderundefined-default._loaderpackages/job-components/src/execution-context/base.ts:30
_methodRegistryprotectedMap<keyof WorkerOperationLifeCycle, Set<number>>undefined-default._methodRegistrypackages/job-components/src/execution-context/base.ts:32
_operationsreadonlySet<WorkerOperationLifeCycle>undefined-default._operationspackages/job-components/src/execution-context/base.ts:31
assetIdsreadonlystring[][]-default.assetIdspackages/job-components/src/execution-context/base.ts:20
configreadonlyExecutionConfigundefined-default.configpackages/job-components/src/execution-context/base.ts:17
contextreadonlyContextundefined-default.contextpackages/job-components/src/execution-context/base.ts:18
eventsreadonlyEventEmitterundefinedThe terafoundation EventEmitterdefault.eventspackages/job-components/src/execution-context/base.ts:26
exIdreadonlystringundefined-default.exIdpackages/job-components/src/execution-context/base.ts:22
jobIdreadonlystringundefined-default.jobIdpackages/job-components/src/execution-context/base.ts:23
loggerreadonlyLoggerundefined-default.loggerpackages/job-components/src/execution-context/base.ts:28
processorsreadonlydefault<OpConfig>[]undefined--packages/job-components/src/execution-context/worker.ts:24
sliceStatepublicundefined | WorkerSliceStateundefinedthe active (or last) run slice-packages/job-components/src/execution-context/worker.ts:27
statuspublicWorkerStatus'initializing'--packages/job-components/src/execution-context/worker.ts:28

Accessors

api

Get Signature

get api(): ExecutionContextAPI

Defined in: packages/job-components/src/execution-context/base.ts:130

Returns

ExecutionContextAPI

Inherited from

default.api


apis

Get Signature

get apis(): JobAPIInstances

Defined in: packages/job-components/src/execution-context/worker.ts:171

Returns

JobAPIInstances


jobObserver

Get Signature

get jobObserver(): default

Defined in: packages/job-components/src/execution-context/worker.ts:175

Returns

default


processingSlice

Get Signature

get processingSlice(): boolean

Defined in: packages/job-components/src/execution-context/worker.ts:271

Returns

boolean

Methods

_resetMethodRegistry()

protected _resetMethodRegistry(): void

Defined in: packages/job-components/src/execution-context/base.ts:182

Returns

void

Inherited from

default._resetMethodRegistry


_runMethod()

protected _runMethod(method, ...args): void

Defined in: packages/job-components/src/execution-context/base.ts:168

Run an method

Parameters

ParameterType
methodkeyof WorkerOperationLifeCycle
...argsany[]

Returns

void

Inherited from

default._runMethod


_runMethodAsync()

protected _runMethodAsync(method, ...args): Promise<any[]>

Defined in: packages/job-components/src/execution-context/base.ts:150

Run an async method on the operation lifecycle

Parameters

ParameterType
methodkeyof WorkerOperationLifeCycle
...argsany[]

Returns

Promise<any[]>

Inherited from

default._runMethodAsync


addOperation()

protected addOperation(op): void

Defined in: packages/job-components/src/execution-context/base.ts:143

Add an operation to the lifecycle queue

Parameters

ParameterType
opWorkerOperationLifeCycle

Returns

void

Inherited from

default.addOperation


fetcher()

fetcher<T>(): T

Defined in: packages/job-components/src/execution-context/worker.ts:167

The instance of a "Fetcher"

Type Parameters

Type ParameterDefault type
T extends default<OpConfig>default<OpConfig>

Returns

T


flush()

flush(): Promise<undefined | RunSliceResult>

Defined in: packages/job-components/src/execution-context/worker.ts:220

Returns

Promise<undefined | RunSliceResult>


getOperation()

getOperation<T>(findBy): T

Defined in: packages/job-components/src/execution-context/worker.ts:144

Get a operation by name or index. If name is used it will return the first match.

Type Parameters

Type ParameterDefault type
T extends default<OpConfig>default<OpConfig>

Parameters

ParameterType
findBystring | number

Returns

T


getOperations()

getOperations(): WorkerOperationLifeCycle[]

Defined in: packages/job-components/src/execution-context/base.ts:138

Returns a list of any registered Operation that has been initialized.

Returns

WorkerOperationLifeCycle[]

Inherited from

default.getOperations


initialize()

initialize(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:127

Called to initialize all of the registered operations

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.initialize

Overrides

default.initialize


initializeSlice()

initializeSlice(slice): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:181

Parameters

ParameterType
sliceSlice

Returns

Promise<void>


onFlushEnd()

onFlushEnd(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:282

Called to notify the processors that the slice is finished being flushed (shutdown will likely be called immediately afterwards)

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onFlushEnd


onFlushStart()

onFlushStart(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:276

Called to notify the processors that the next slice being passed through will be an empty slice used to flush any additional in-memory state.

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onFlushStart


onSliceFailed()

onSliceFailed(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:307

Called after the slice has been marked as "Failed"

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceFailed


onSliceFinalizing()

onSliceFinalizing(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:297

Called after a slice is done with the last operation in the execution

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceFinalizing


onSliceFinished()

onSliceFinished(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:302

Called after the slice has been acknowledged by the "Execution Controller"

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceFinished


onSliceInitialized()

onSliceInitialized(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:287

Called after a slice is initializated, but before the slice has been handed to any operation.

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceInitialized


onSliceRetry()

onSliceRetry(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:313

Called after the operation failed to process the slice but before the slice is retried.

NOTE: A retry can be stopped by throw an error inside this function

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceRetry


onSliceStarted()

onSliceStarted(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:292

Called after a the slice is sent to the "Fetcher"

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceStarted


runSlice()

runSlice(slice?): Promise<RunSliceResult>

Defined in: packages/job-components/src/execution-context/worker.ts:202

Run a slice against the fetcher and then processors.

Parameters

ParameterType
slice?Slice

Returns

Promise<RunSliceResult>

Todo

this should handle slice retries.


shutdown()

shutdown(): Promise<void>

Defined in: packages/job-components/src/execution-context/worker.ts:132

Called to cleanup all of the registered operations

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.shutdown

Overrides

default.shutdown


createContext()

static createContext(config): Promise<WorkerExecutionContext>

Defined in: packages/job-components/src/execution-context/worker.ts:51

Parameters

ParameterType
configExecutionContextConfig

Returns

Promise<WorkerExecutionContext>