@terascope/job-components / operations/core/operation-core / default
Class: default<T>
Defined in: job-components/src/operations/core/operation-core.ts:18
A base class for supporting operations that run on a "Worker", that supports the job execution lifecycle events. This class will likely not be used externally since Teraslice only supports a few types varients based on this class.
See [[Core]] more information
Extends
Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
T | OpConfig |
Implements
Constructors
Constructor
new default<
T>(context,opConfig,executionConfig):OperationCore<T>
Defined in: job-components/src/operations/core/operation-core.ts:25
Parameters
| Parameter | Type |
|---|---|
context | Context |
opConfig | OpConfig & T |
executionConfig | ExecutionConfig |
Returns
OperationCore<T>
Overrides
Properties
| Property | Modifier | Type | Inherited from | Defined in |
|---|---|---|---|---|
context | readonly | Readonly<T> | default.context | job-components/src/operations/core/core.ts:10 |
deadLetterAction | public | string | - | job-components/src/operations/core/operation-core.ts:23 |
events | readonly | EventEmitter | default.events | job-components/src/operations/core/core.ts:13 |
executionConfig | readonly | Readonly<ExecutionConfig> | default.executionConfig | job-components/src/operations/core/core.ts:11 |
logger | readonly | Logger | default.logger | job-components/src/operations/core/core.ts:12 |
opConfig | readonly | Readonly<OpConfig & T> | - | job-components/src/operations/core/operation-core.ts:22 |
Methods
createAPI()
createAPI<
A>(name, ...params):Promise<A>
Defined in: job-components/src/operations/core/operation-core.ts:46
Create an API and add it to the operation lifecycle
Type Parameters
| Type Parameter | Default type |
|---|---|
A extends OpAPI | OpAPI |
Parameters
| Parameter | Type |
|---|---|
name | string |
...params | any[] |
Returns
Promise<A>
getAPI()
getAPI<
A>(name):A
Defined in: job-components/src/operations/core/operation-core.ts:53
Get a reference to an existing API
Type Parameters
| Type Parameter | Default type |
|---|---|
A extends OpAPI | OpAPI |
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
A
initialize()
initialize():
Promise<void>
Defined in: job-components/src/operations/core/operation-core.ts:35
Called during execution initialization, when this is called perform any async setup.
Returns
Promise<void>
Implementation of
WorkerOperationLifeCycle.initialize
Overrides
rejectRecord()
rejectRecord(
input,err):null
Defined in: job-components/src/operations/core/operation-core.ts:91
Reject a record using the dead letter action
Based on OpConfig._dead_letter_action the transformation can be handled any of the following ways:
- "throw": throw the original error
- "log": log the error and the data
- "none": skip the error entirely OR a string to specify the api to use as the dead letter queue
Parameters
| Parameter | Type |
|---|---|
input | unknown |
err | Error |
Returns
null
null
shutdown()
shutdown():
Promise<void>
Defined in: job-components/src/operations/core/operation-core.ts:39
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
tryRecord()
tryRecord<
I,R>(fn): (input) =>R|null
Defined in: job-components/src/operations/core/operation-core.ts:66
Try catch a transformation on a record and place any failed records in a dead letter queue
See #rejectRecord for handling
Type Parameters
| Type Parameter |
|---|
I |
R |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | (input) => R | a function to transform the data with |
Returns
a curried a function that will be called with the data and handle the dead letter action
(
input):R|null
Parameters
| Parameter | Type |
|---|---|
input | I |
Returns
R | null