Job Components: `Execution Context Worker Worker Execution Context`
execution-context/worker.WorkerExecutionContext
WorkerExecutionContext is designed to add more functionality to interface with the Execution Configuration and any Operation.
Hierarchy
default
<WorkerOperationLifeCycle
>↳
WorkerExecutionContext
Implements
Table of contents
Constructors
Properties
- _loader
- _methodRegistry
- _operations
- assetIds
- config
- context
- events
- exId
- jobId
- logger
- processors
- sliceState
- status
Accessors
Methods
- _resetMethodRegistry
- _runMethod
- _runMethodAsync
- addOperation
- fetcher
- flush
- getOperation
- getOperations
- initialize
- initializeSlice
- onFlushEnd
- onFlushStart
- onSliceFailed
- onSliceFinalizing
- onSliceFinished
- onSliceInitialized
- onSliceRetry
- onSliceStarted
- runSlice
- shutdown
Constructors
constructor
• new WorkerExecutionContext(config
): WorkerExecutionContext
Parameters
Name | Type |
---|---|
config | ExecutionContextConfig |
Returns
Overrides
Defined in
packages/job-components/src/execution-context/worker.ts:33
Properties
_loader
• Protected
Readonly
_loader: OperationLoader
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:28
_methodRegistry
• Protected
_methodRegistry: Map
<keyof WorkerOperationLifeCycle
, Set
<number
>>
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:30
_operations
• Protected
Readonly
_operations: Set
<WorkerOperationLifeCycle
>
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:29
assetIds
• Readonly
assetIds: string
[] = []
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:18
config
• Readonly
config: ExecutionConfig
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:15
context
• Readonly
context: WorkerContext
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:16
events
• Readonly
events: EventEmitter
The terafoundation EventEmitter
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:24
exId
• Readonly
exId: string
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:20
jobId
• Readonly
jobId: string
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:21
logger
• Readonly
logger: Logger
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:26
processors
• Readonly
processors: default
<OpConfig
>[]
Defined in
packages/job-components/src/execution-context/worker.ts:24
sliceState
• sliceState: undefined
| WorkerSliceState
the active (or last) run slice
Defined in
packages/job-components/src/execution-context/worker.ts:27
status
• status: WorkerStatus
= 'initializing'
Defined in
packages/job-components/src/execution-context/worker.ts:28
Accessors
api
• get
api(): ExecutionContextAPI
Returns
Inherited from
BaseExecutionContext.api
Defined in
packages/job-components/src/execution-context/base.ts:125
apis
• get
apis(): JobAPIInstances
Returns
Defined in
packages/job-components/src/execution-context/worker.ts:162
jobObserver
• get
jobObserver(): default
Returns
Defined in
packages/job-components/src/execution-context/worker.ts:166
processingSlice
• get
processingSlice(): boolean
Returns
boolean
Defined in
packages/job-components/src/execution-context/worker.ts:262
Methods
_resetMethodRegistry
▸ _resetMethodRegistry(): void
Returns
void
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:177
_runMethod
▸ _runMethod(method
, ...args
): void
Run an method
Parameters
Name | Type |
---|---|
method | keyof WorkerOperationLifeCycle |
...args | any [] |
Returns
void
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:163
_runMethodAsync
▸ _runMethodAsync(method
, ...args
): Promise
<any
[]>
Run an async method on the operation lifecycle
Parameters
Name | Type |
---|---|
method | keyof WorkerOperationLifeCycle |
...args | any [] |
Returns
Promise
<any
[]>
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:145
addOperation
▸ addOperation(op
): void
Add an operation to the lifecycle queue
Parameters
Name | Type |
---|---|
op | WorkerOperationLifeCycle |
Returns
void
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:138
fetcher
▸ fetcher<T
>(): T
The instance of a "Fetcher"
Type parameters
Name | Type |
---|---|
T | extends default <OpConfig > = default <OpConfig > |
Returns
T
Defined in
packages/job-components/src/execution-context/worker.ts:158
flush
▸ flush(): Promise
<undefined
| RunSliceResult
>
Returns
Promise
<undefined
| RunSliceResult
>
Defined in
packages/job-components/src/execution-context/worker.ts:211
getOperation
▸ getOperation<T
>(findBy
): T
Get a operation by name or index. If name is used it will return the first match.
Type parameters
Name | Type |
---|---|
T | extends default <OpConfig > = default <OpConfig > |
Parameters
Name | Type | |
---|---|---|
findBy | string \ | number |
Returns
T
Defined in
packages/job-components/src/execution-context/worker.ts:135
getOperations
▸ getOperations(): WorkerOperationLifeCycle
[]
Returns a list of any registered Operation that has been initialized.
Returns
Inherited from
Defined in
packages/job-components/src/execution-context/base.ts:133
initialize
▸ initialize(): Promise
<void
>
Called during execution initialization, when this is called perform any async setup.
Returns
Promise
<void
>
Implementation of
WorkerOperationLifeCycle.initialize
Overrides
Defined in
packages/job-components/src/execution-context/worker.ts:118
initializeSlice
▸ initializeSlice(slice
): Promise
<void
>
Parameters
Name | Type |
---|---|
slice | Slice |
Returns
Promise
<void
>
Defined in
packages/job-components/src/execution-context/worker.ts:172
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
Defined in
packages/job-components/src/execution-context/worker.ts:273
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
Defined in
packages/job-components/src/execution-context/worker.ts:267
onSliceFailed
▸ onSliceFailed(): Promise
<void
>
Called after the slice has been marked as "Failed"
Returns
Promise
<void
>
Implementation of
WorkerOperationLifeCycle.onSliceFailed
Defined in
packages/job-components/src/execution-context/worker.ts:298
onSliceFinalizing
▸ onSliceFinalizing(): Promise
<void
>
Called after a slice is done with the last operation in the execution
Returns
Promise
<void
>
Implementation of
WorkerOperationLifeCycle.onSliceFinalizing
Defined in
packages/job-components/src/execution-context/worker.ts:288
onSliceFinished
▸ onSliceFinished(): Promise
<void
>
Called after the slice has been acknowledged by the "Execution Controller"
Returns
Promise
<void
>
Implementation of
WorkerOperationLifeCycle.onSliceFinished
Defined in
packages/job-components/src/execution-context/worker.ts:293
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
Defined in
packages/job-components/src/execution-context/worker.ts:278
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
Defined in
packages/job-components/src/execution-context/worker.ts:304
onSliceStarted
▸ onSliceStarted(): Promise
<void
>
Called after a the slice is sent to the "Fetcher"
Returns
Promise
<void
>
Implementation of
WorkerOperationLifeCycle.onSliceStarted
Defined in
packages/job-components/src/execution-context/worker.ts:283
runSlice
▸ runSlice(slice?
): Promise
<RunSliceResult
>
Run a slice against the fetcher and then processors.
Parameters
Name | Type |
---|---|
slice? | Slice |
Returns
Promise
<RunSliceResult
>
Todo
this should handle slice retries.
Defined in
packages/job-components/src/execution-context/worker.ts:193
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