Skip to main content

@terascope/job-components / operations/operation-api / default

Class: abstract default<T>

Defined in: packages/job-components/src/operations/operation-api.ts:7

An API factory class for operations

Extends

Extended by

Type Parameters

Type ParameterDefault type
TAPIConfig

Constructors

new default()

new default<T>(context, apiConfig, executionConfig): default<T>

Defined in: packages/job-components/src/operations/core/api-core.ts:23

Parameters

ParameterType
contextContext
apiConfigAPIConfig & T
executionConfigExecutionConfig

Returns

default<T>

Inherited from

default.constructor

Properties

PropertyModifierTypeInherited fromDefined in
apiConfigreadonlyReadonly<APIConfig & T>default.apiConfigpackages/job-components/src/operations/core/api-core.ts:20
contextreadonlyReadonly<Context>default.contextpackages/job-components/src/operations/core/core.ts:10
deadLetterActionpublicstringdefault.deadLetterActionpackages/job-components/src/operations/core/api-core.ts:21
eventsreadonlyEventEmitterdefault.eventspackages/job-components/src/operations/core/core.ts:13
executionConfigreadonlyReadonly<ExecutionConfig>default.executionConfigpackages/job-components/src/operations/core/core.ts:11
loggerreadonlyLoggerdefault.loggerpackages/job-components/src/operations/core/core.ts:12

Methods

createAPI()

abstract createAPI(...params): Promise<OpAPI>

Defined in: packages/job-components/src/operations/operation-api.ts:16

Called when the API is created with in another Operation. This will only be called once during an operation

Parameters

ParameterType
...paramsany[]

Returns

Promise<OpAPI>

an Operation API which is one of the following

  • an object with function properties
  • an instances of a class
  • a function

initialize()

initialize(): Promise<void>

Defined in: packages/job-components/src/operations/core/api-core.ts:37

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

Returns

Promise<void>

Inherited from

default.initialize


rejectRecord()

rejectRecord(input, err): null

Defined in: packages/job-components/src/operations/core/api-core.ts:79

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

ParameterType
inputunknown
errError

Returns

null

null

Inherited from

default.rejectRecord


shutdown()

shutdown(): Promise<void>

Defined in: packages/job-components/src/operations/core/api-core.ts:41

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

Returns

Promise<void>

Inherited from

default.shutdown


tryRecord()

tryRecord<I, R>(fn): (input) => null | R

Defined in: packages/job-components/src/operations/core/api-core.ts:54

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

ParameterTypeDescription
fn(input) => Ra function to transform the data with

Returns

Function

a curried a function that will be called with the data and handle the dead letter action

Parameters
ParameterType
inputI
Returns

null | R

Inherited from

default.tryRecord