@proto-kit/sequencer • Docs
Documentation / @proto-kit/sequencer / ReductionTaskFlow
Class: ReductionTaskFlow<Input, Output>
This class builds and executes a flow that follows the map-reduce pattern. This works in 2 steps:
- Mapping: Execute the mappingTask to transform from Input -> Output
- Reduction: Find suitable pairs and merge them [Output, Output] -> Output
We use this pattern extensively in our pipeline,
Type Parameters
• Input
• Output
Constructors
new ReductionTaskFlow()
new ReductionTaskFlow<
Input,Output>(options,flowCreator):ReductionTaskFlow<Input,Output>
Parameters
• options
• options.inputLength: number
• options.mappingTask: Task<Input, Output>
• options.mergableFunction
• options.name: string
• options.reductionTask: Task<PairTuple<Output>, Output>
• flowCreator: FlowCreator
Returns
ReductionTaskFlow<Input, Output>
Defined in
packages/sequencer/src/protocol/production/flow/ReductionTaskFlow.ts:37
Properties
flow
readonlyflow:Flow<ReductionState<Output>>
Defined in
packages/sequencer/src/protocol/production/flow/ReductionTaskFlow.ts:31
Methods
deferErrorsTo()
deferErrorsTo(
flow):void
To be used in conjunction with onCompletion It allows errors from this flow to be “deferred” to another parent flow which might be properly awaited and therefore will throw the error up to the user
Parameters
• flow: Flow<unknown>
Returns
void
Defined in
packages/sequencer/src/protocol/production/flow/ReductionTaskFlow.ts:184
execute()
execute(
inputs):Promise<Output>
Execute the flow using the returned Promise that resolved when the flow is finished
Parameters
• inputs: Input[] = []
initial inputs - doesnt have to be the complete set of inputs
Returns
Promise<Output>
Defined in
packages/sequencer/src/protocol/production/flow/ReductionTaskFlow.ts:193
onCompletion()
onCompletion(
callback):void
Execute the flow using a callback method that is invoked upon completion of the flow. Push inputs using pushInput()
Parameters
• callback
Returns
void
Defined in
packages/sequencer/src/protocol/production/flow/ReductionTaskFlow.ts:173
pushInput()
pushInput(
input):Promise<void>
Parameters
• input: Input
Returns
Promise<void>
Defined in
packages/sequencer/src/protocol/production/flow/ReductionTaskFlow.ts:205