API Reference
thecodecrate_pipeline
__all__
module-attribute
__all__ = (
"Pipeline",
"PipelineFactory",
"PipelineFactoryInterface",
"PipelineInterface",
"Processor",
"ProcessorInterface",
"Stage",
"StageInterface",
)
Pipeline
Pipeline(
processor: Optional[type[Processor] | Processor] = None,
processor_instance: Optional[Processor] = None,
*args: Any,
**kwds: Any
)
__call__
async
Processes payload through the pipeline.
process
async
Process the given payload through the pipeline.
with_processor
with_processor(
processor: type[Processor] | Processor,
) -> Self
Attachs a processor (class or instance) to the pipeline.
with_stages
with_stages(stages: StageDefinitionCollection) -> Self
Adds a collection of stages to the pipeline.
PipelineFactory
PipelineFactory(
stages: Optional[StageDefinitionCollection] = None,
processor: Optional[type[Processor] | Processor] = None,
pipeline_class: Optional[
type[Pipeline[T_in, T_out]]
] = None,
*args: Any,
**kwds: Any
)
add_stage
add_stage(stage: StageDefinition) -> Self
Add a single stage (class, object or function) to the pipeline.
with_processor
with_processor(
processor: type[Processor] | Processor,
) -> Self
Attach a processor (class or instance) to the pipeline factory.
with_stages
with_stages(stages: StageDefinitionCollection) -> Self
Set a collection of stages (class, object or function) to the pipeline.
Processor
_call
async
_call(
callable: CallableType[T_in, T_out],
payload: T_in,
*args: Any,
**kwds: Any
) -> T_out
Do the actual processing of the payload - the "process" method is just an alias to this method.
process
abstractmethod
async
Process the given payload through the provided stages.
Parameters:
-
(payloadT_in) –The input payload to process.
-
(stagesCallableCollection) –The collection of stages to process the payload through.
-
(*argsAny, default:()) –Additional positional arguments.
-
(**kwdsAny, default:{}) –Additional keyword arguments.
Returns:
-
T_out(T_out) –The processed output.
Stage
__call__
abstractmethod
async
Runs the stage.