AttemptMiddleware
AttemptMiddleware<
TStateAdapter,THandlerCtx,TPrepareCtx,TStepCtx,TCompleteCtx> =object
Defined in: packages/core/src/worker/attempt-middleware.ts:38
Wraps job processing with cross-cutting logic for one or more phases.
Each hook is optional — implement only the phases you need. The next(ctx)
callback injects typed context that becomes available to the inner handler:
wrapHandler— wraps the entire attempt handler. Injected ctx is merged intoattemptHandler’s options.wrapPrepare— wraps the user-supplied prepare callback. Injected ctx is merged into the callback’s options alongside the transaction context.wrapStep— wraps each user-supplied step callback. Injected ctx is merged into the callback’s options alongsidetransactionHooksand the transaction context.wrapComplete— wraps the user-supplied complete callback. Injected ctx is merged into the callback’s options alongsidefinish,transactionHooks, and the transaction context.
Multiple middleware compose as an onion — the first middleware’s “before” runs
outermost. Each next(ctx) accumulates ctx for inner layers.
Type Parameters
Section titled “Type Parameters”TStateAdapter
Section titled “TStateAdapter”TStateAdapter extends StateAdapter<any, any>
THandlerCtx
Section titled “THandlerCtx”THandlerCtx extends Record<string, unknown> = Record<string, unknown>
TPrepareCtx
Section titled “TPrepareCtx”TPrepareCtx extends Record<string, unknown> = Record<string, unknown>
TStepCtx
Section titled “TStepCtx”TStepCtx extends Record<string, unknown> = Record<string, unknown>
TCompleteCtx
Section titled “TCompleteCtx”TCompleteCtx extends Record<string, unknown> = Record<string, unknown>
Properties
Section titled “Properties”wrapComplete?
Section titled “wrapComplete?”
optionalwrapComplete?: <T>(opts) =>Promise<T>
Defined in: packages/core/src/worker/attempt-middleware.ts:63
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”object & GetStateAdapterTxContext<TStateAdapter>
Returns
Section titled “Returns”Promise<T>
wrapHandler?
Section titled “wrapHandler?”
optionalwrapHandler?: <T>(opts) =>Promise<T>
Defined in: packages/core/src/worker/attempt-middleware.ts:45
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”RunningJob<TStateAdapter>
(ctx) => Promise<T>
workerId
Section titled “workerId”string
Returns
Section titled “Returns”Promise<T>
wrapPrepare?
Section titled “wrapPrepare?”
optionalwrapPrepare?: <T>(opts) =>Promise<T>
Defined in: packages/core/src/worker/attempt-middleware.ts:50
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”object & GetStateAdapterTxContext<TStateAdapter>
Returns
Section titled “Returns”Promise<T>
wrapStep?
Section titled “wrapStep?”
optionalwrapStep?: <T>(opts) =>Promise<T>
Defined in: packages/core/src/worker/attempt-middleware.ts:56
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”object & GetStateAdapterTxContext<TStateAdapter>
Returns
Section titled “Returns”Promise<T>