Skip to main content

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

Class: WorkerExecutionContext

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

Parameters

ParameterType
configExecutionContextConfig

Returns

WorkerExecutionContext

Overrides

default.constructor

Source

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

Properties

_loader

protected readonly _loader: OperationLoader

Inherited from

default._loader

Source

packages/job-components/src/execution-context/base.ts:30


_methodRegistry

protected _methodRegistry: Map<keyof WorkerOperationLifeCycle, Set<number>>

Inherited from

default._methodRegistry

Source

packages/job-components/src/execution-context/base.ts:32


_operations

protected readonly _operations: Set<WorkerOperationLifeCycle>

Inherited from

default._operations

Source

packages/job-components/src/execution-context/base.ts:31


assetIds

readonly assetIds: string[] = []

Inherited from

default.assetIds

Source

packages/job-components/src/execution-context/base.ts:20


config

readonly config: ExecutionConfig

Inherited from

default.config

Source

packages/job-components/src/execution-context/base.ts:17


context

readonly context: Context

Inherited from

default.context

Source

packages/job-components/src/execution-context/base.ts:18


events

readonly events: EventEmitter<DefaultEventMap>

The terafoundation EventEmitter

Inherited from

default.events

Source

packages/job-components/src/execution-context/base.ts:26


exId

readonly exId: string

Inherited from

default.exId

Source

packages/job-components/src/execution-context/base.ts:22


jobId

readonly jobId: string

Inherited from

default.jobId

Source

packages/job-components/src/execution-context/base.ts:23


logger

readonly logger: Logger

Inherited from

default.logger

Source

packages/job-components/src/execution-context/base.ts:28


processors

readonly processors: default<OpConfig>[]

Source

packages/job-components/src/execution-context/worker.ts:24


sliceState

sliceState: undefined | WorkerSliceState

the active (or last) run slice

Source

packages/job-components/src/execution-context/worker.ts:27


status

status: WorkerStatus = 'initializing'

Source

packages/job-components/src/execution-context/worker.ts:28

Accessors

api

get api(): ExecutionContextAPI

Returns

ExecutionContextAPI

Source

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


apis

get apis(): JobAPIInstances

Returns

JobAPIInstances

Source

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


jobObserver

get jobObserver(): default

Returns

default

Source

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


processingSlice

get processingSlice(): boolean

Returns

boolean

Source

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

Methods

_resetMethodRegistry()

protected _resetMethodRegistry(): void

Returns

void

Inherited from

default._resetMethodRegistry

Source

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


_runMethod()

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

Run an method

Parameters

ParameterType
methodkeyof WorkerOperationLifeCycle
...argsany[]

Returns

void

Inherited from

default._runMethod

Source

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


_runMethodAsync()

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

Run an async method on the operation lifecycle

Parameters

ParameterType
methodkeyof WorkerOperationLifeCycle
...argsany[]

Returns

Promise<any[]>

Inherited from

default._runMethodAsync

Source

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


addOperation()

protected addOperation(op): void

Add an operation to the lifecycle queue

Parameters

ParameterType
opWorkerOperationLifeCycle

Returns

void

Inherited from

default.addOperation

Source

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


fetcher()

fetcher<T>(): T

The instance of a "Fetcher"

Type parameters

Type parameterValue
T extends default<OpConfig>default<OpConfig>

Returns

T

Source

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


flush()

flush(): Promise<undefined | RunSliceResult>

Returns

Promise<undefined | RunSliceResult>

Source

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


getOperation()

getOperation<T>(findBy): T

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

Type parameters

Type parameterValue
T extends default<OpConfig>default<OpConfig>

Parameters

ParameterType
findBystring | number

Returns

T

Source

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


getOperations()

getOperations(): WorkerOperationLifeCycle[]

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

Returns

WorkerOperationLifeCycle[]

Inherited from

default.getOperations

Source

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


initialize()

initialize(): Promise<void>

Called during execution initialization, when this is called perform any async setup.

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.initialize

Overrides

default.initialize

Source

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


initializeSlice()

initializeSlice(slice): Promise<void>

Parameters

ParameterType
sliceSlice

Returns

Promise<void>

Source

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


onFlushEnd()

onFlushEnd(): Promise<void>

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

Source

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


onFlushStart()

onFlushStart(): Promise<void>

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

Source

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


onSliceFailed()

onSliceFailed(): Promise<void>

Called after the slice has been marked as "Failed"

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceFailed

Source

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


onSliceFinalizing()

onSliceFinalizing(): Promise<void>

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

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceFinalizing

Source

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


onSliceFinished()

onSliceFinished(): Promise<void>

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

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceFinished

Source

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


onSliceInitialized()

onSliceInitialized(): Promise<void>

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

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceInitialized

Source

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


onSliceRetry()

onSliceRetry(): Promise<void>

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

Source

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


onSliceStarted()

onSliceStarted(): Promise<void>

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

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.onSliceStarted

Source

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


runSlice()

runSlice(slice?): Promise<RunSliceResult>

Run a slice against the fetcher and then processors.

Parameters

ParameterType
slice?Slice

Returns

Promise<RunSliceResult>

Todo

this should handle slice retries.

Source

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


shutdown()

shutdown(): Promise<void>

Called during execution shutdown, when this is cleanup any open connections or destroy any in-memory state.

Returns

Promise<void>

Implementation of

WorkerOperationLifeCycle.shutdown

Overrides

default.shutdown

Source

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


createContext()

static createContext(config): Promise<WorkerExecutionContext>

Parameters

ParameterType
configExecutionContextConfig

Returns

Promise<WorkerExecutionContext>

Source

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