import Core from './core.js'; import { ExecutionConfig, WorkerOperationLifeCycle, OpAPI, OpConfig, Context, DeadLetterAction } from '../../interfaces/index.js'; /** * 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 */ export default class OperationCore extends Core implements WorkerOperationLifeCycle { readonly opConfig: Readonly; deadLetterAction: DeadLetterAction; constructor(context: Context, opConfig: OpConfig & T, executionConfig: ExecutionConfig); initialize(): Promise; shutdown(): Promise; /** * Create an API and add it to the operation lifecycle */ createAPI(name: string, ...params: any[]): Promise; /** * Get a reference to an existing API */ getAPI(name: string): A; /** * Try catch a transformation on a record and place any failed records in a dead letter queue * * See {@link #rejectRecord} for handling * * @param fn 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 */ tryRecord(fn: (input: I) => R): (input: I) => R | null; /** * Reject a record using the dead letter action * * Based on {@link 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 * * @param data the data to transform * @param fn a function to transform the data with * @returns null */ rejectRecord(input: unknown, err: Error): never | null; } //# sourceMappingURL=operation-core.d.ts.map