Skip to main content

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

Class: abstract default<T, C>

An API factory class for operations

Extends

Type parameters

Type parameter
T
C

Constructors

new default()

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

Parameters

ParameterType
contextContext
apiConfigAPIConfig
executionConfigExecutionConfig

Returns

default<T, C>

Inherited from

default.constructor

Source

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

Properties

_configRegistry

protected readonly _configRegistry: Map<string, C>

Source

packages/job-components/src/operations/api-factory.ts:6


_registry

protected readonly _registry: Map<string, T>

Source

packages/job-components/src/operations/api-factory.ts:5


apiConfig

readonly apiConfig: Readonly<APIConfig>

Inherited from

default.apiConfig

Source

packages/job-components/src/operations/core/api-core.ts:20


context

readonly context: Readonly<Context>

Inherited from

default.context

Source

packages/job-components/src/operations/core/core.ts:10


deadLetterAction

deadLetterAction: string

Inherited from

default.deadLetterAction

Source

packages/job-components/src/operations/core/api-core.ts:21


events

readonly events: EventEmitter<DefaultEventMap>

Inherited from

default.events

Source

packages/job-components/src/operations/core/core.ts:13


executionConfig

readonly executionConfig: Readonly<ExecutionConfig>

Inherited from

default.executionConfig

Source

packages/job-components/src/operations/core/core.ts:11


logger

readonly logger: Logger

Inherited from

default.logger

Source

packages/job-components/src/operations/core/core.ts:12

Methods

create()

abstract create(name, config): Promise<object>

Parameters

ParameterType
namestring
configPartial<C>

Returns

Promise<object>

client

client: T

config

config: C

Source

packages/job-components/src/operations/api-factory.ts:8


createAPI()

createAPI(): Promise<APIFactoryRegistry<T, C>>

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

Returns

Promise<APIFactoryRegistry<T, C>>

an Operation API which is one of the following

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

Overrides

default.createAPI

Source

packages/job-components/src/operations/api-factory.ts:15


initialize()

initialize(): Promise<void>

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

Returns

Promise<void>

Inherited from

default.initialize

Source

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


rejectRecord()

rejectRecord(input, err): null

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

Source

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


remove()

abstract remove(name): Promise<void>

Parameters

ParameterType
namestring

Returns

Promise<void>

Source

packages/job-components/src/operations/api-factory.ts:13


shutdown()

shutdown(): Promise<void>

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

Returns

Promise<void>

Inherited from

default.shutdown

Source

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


tryRecord()

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

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

Source

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