Skip to main content

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

Class: WorkerExecutionContext

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

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

Extends​

Implements​

Constructors​

Constructor​

new WorkerExecutionContext(config): WorkerExecutionContext

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

Parameters​

ParameterType
configExecutionContextConfig

Returns​

WorkerExecutionContext

Overrides​

default.constructor

Properties​

PropertyModifierTypeDefault valueDescriptionInherited fromDefined in
_loaderreadonlyOperationLoaderundefined-default._loaderjob-components/src/execution-context/base.ts:30
_methodRegistryprotectedMap<keyof WorkerOperationLifeCycle, Set<number>>undefined-default._methodRegistryjob-components/src/execution-context/base.ts:32
_operationsreadonlySet<WorkerOperationLifeCycle>undefined-default._operationsjob-components/src/execution-context/base.ts:31
assetIdsreadonlystring[][]-default.assetIdsjob-components/src/execution-context/base.ts:20
configreadonlyExecutionConfigundefined-default.configjob-components/src/execution-context/base.ts:17
contextreadonlyContextundefined-default.contextjob-components/src/execution-context/base.ts:18
eventsreadonlyEventEmitterundefinedThe terafoundation EventEmitterdefault.eventsjob-components/src/execution-context/base.ts:26
exIdreadonlystringundefined-default.exIdjob-components/src/execution-context/base.ts:22
jobIdreadonlystringundefined-default.jobIdjob-components/src/execution-context/base.ts:23
loggerreadonlyLoggerundefined-default.loggerjob-components/src/execution-context/base.ts:28
processorsreadonlydefault<OpConfig>[]undefined--job-components/src/execution-context/worker.ts:26
sliceStatepublicWorkerSliceState | undefinedundefinedthe active (or last) run slice-job-components/src/execution-context/worker.ts:29
statuspublicWorkerStatus'initializing'--job-components/src/execution-context/worker.ts:30

Accessors​

api​

Get Signature​

get api(): ExecutionContextAPI

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

Returns​

ExecutionContextAPI

Inherited from​

default.api


apis​

Get Signature​

get apis(): JobAPIInstances

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

Returns​

JobAPIInstances


jobObserver​

Get Signature​

get jobObserver(): default

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

Returns​

default


processingSlice​

Get Signature​

get processingSlice(): boolean

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

Returns​

boolean


tapObserver​

Get Signature​

get tapObserver(): default

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

Returns​

default

Methods​

_resetMethodRegistry()​

protected _resetMethodRegistry(): void

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

Returns​

void

Inherited from​

default._resetMethodRegistry


_runMethod()​

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

Defined in: 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: 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: 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: job-components/src/execution-context/worker.ts:174

The instance of a "Fetcher"

Type Parameters​

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

Returns​

T


flush()​

flush(): Promise<RunSliceResult | undefined>

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

Returns​

Promise<RunSliceResult | undefined>


getOperation()​

getOperation<T>(findBy): T

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

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: 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: job-components/src/execution-context/worker.ts:134

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: job-components/src/execution-context/worker.ts:194

Parameters​

ParameterType
sliceSlice

Returns​

Promise<void>


onFlushEnd()​

onFlushEnd(): Promise<void>

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

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: job-components/src/execution-context/worker.ts:289

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: job-components/src/execution-context/worker.ts:320

Called after the slice has been marked as "Failed"

Returns​

Promise<void>

Implementation of​

WorkerOperationLifeCycle.onSliceFailed


onSliceFinalizing()​

onSliceFinalizing(): Promise<void>

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

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: job-components/src/execution-context/worker.ts:315

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

Returns​

Promise<void>

Implementation of​

WorkerOperationLifeCycle.onSliceFinished


onSliceInitialized()​

onSliceInitialized(): Promise<void>

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

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

Returns​

Promise<void>

Implementation of​

WorkerOperationLifeCycle.onSliceInitialized


onSliceRetry()​

onSliceRetry(): Promise<void>

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

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: job-components/src/execution-context/worker.ts:305

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

Returns​

Promise<void>

Implementation of​

WorkerOperationLifeCycle.onSliceStarted


runSlice()​

runSlice(slice?): Promise<RunSliceResult>

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

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: job-components/src/execution-context/worker.ts:139

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: job-components/src/execution-context/worker.ts:54

Parameters​

ParameterType
configExecutionContextConfig

Returns​

Promise<WorkerExecutionContext>