Skip to main content

@terascope/job-components / operations/tap-observer / default

Class: default

Defined in: job-components/src/operations/tap-observer.ts:13

An Observer for collecting a slice tap.

The lifecycle methods run inside the slice pipeline and must never throw, so a failed tap cannot fail the slice. Record the error on pending.failure instead, and let getTap reject with it.

Extends​

Constructors​

Constructor​

new default(context, apiConfig, executionConfig): TapObserver

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

Parameters​

ParameterType
contextContext
apiConfigAPIConfig
executionConfigExecutionConfig

Returns​

TapObserver

Inherited from​

default.constructor

Properties​

PropertyModifierTypeInherited fromDefined in
apiConfigreadonlyReadonly<APIConfig & T>default.apiConfigjob-components/src/operations/core/api-core.ts:20
contextreadonlyReadonly<T>default.contextjob-components/src/operations/core/core.ts:10
deadLetterActionpublicstringdefault.deadLetterActionjob-components/src/operations/core/api-core.ts:21
eventsreadonlyEventEmitterdefault.eventsjob-components/src/operations/core/core.ts:13
executionConfigreadonlyReadonly<ExecutionConfig>default.executionConfigjob-components/src/operations/core/core.ts:11
loggerreadonlyLoggerdefault.loggerjob-components/src/operations/core/core.ts:12

Methods​

getTap()​

getTap(size, timeoutMs): Promise<SliceTapResults>

Defined in: job-components/src/operations/tap-observer.ts:70

Collect a tap from the next slice this worker starts.

Parameters​

ParameterType
sizenumber
timeoutMsnumber

Returns​

Promise<SliceTapResults>


initialize()​

initialize(): Promise<void>

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

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

Returns​

Promise<void>

Inherited from​

default.initialize


onOperationComplete()​

onOperationComplete(sliceId, index, processed, records): void

Defined in: job-components/src/operations/tap-observer.ts:22

Parameters​

ParameterType
sliceIdstring
indexnumber
processednumber
recordsDataEntity<Record<string, any>, _DataEntityMetadata<Record<string, any>>>[]

Returns​

void


onSliceFailed()​

onSliceFailed(sliceId): void

Defined in: job-components/src/operations/tap-observer.ts:49

Parameters​

ParameterType
sliceIdstring

Returns​

void


onSliceFinalizing()​

onSliceFinalizing(sliceId): void

Defined in: job-components/src/operations/tap-observer.ts:45

Parameters​

ParameterType
sliceIdstring

Returns​

void


onSliceInitialized()​

onSliceInitialized(sliceId): void

Defined in: job-components/src/operations/tap-observer.ts:16

Parameters​

ParameterType
sliceIdstring

Returns​

void


rejectRecord()​

rejectRecord(input, err): null

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

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: job-components/src/operations/tap-observer.ts:59

Send failure error if worker is shutting down. Shutdown should only be called after the slice finishes, so this is just a precaution.

Returns​

Promise<void>

Overrides​

default.shutdown


tryRecord()​

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

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

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​

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

(input) => R | null

Inherited from​

default.tryRecord