Skip to content

Core Concepts

Feeder

Feeder[FirstInput, Input, Output] defines a pipeline's node.

class Feeder(Protocol[FirstInput, Input, Output]):
    async def __call__(self, input: Input) -> Output:
        """
        Processes an input of type `Input` and produces an output of type `Output`.
        """

        ...

    async def feed(self, input: FirstInput) -> Output:
        """
        Feeds a chain of Feeders starting from an initial input of type `FirstInput`
        and produces an output of type `Output`.
        """

        ...

As the name suggests, a Feeder is responsible for "feeding" data through a pipeline.

  • If it's the node's turn to process data locally, it is executed via __call__ with the input of type Input.
  • If .feed() is called, it triggers a backward traversal to the pipeline's starting point, taking an input of type FirstInput, and processes data through the entire chain of Feeders until it reaches the node itself, returning the final output of type Output.

All nodes defined in Chorey are Feeders, including Step, Branch and Route.

The Three Type Arguments

The three generic type arguments are the foundation of Chorey's strict, end-to-end type safety.

Type Argument Role Type-lifetime Description
FirstInput The very first input type of the entire pipeline Entire Pipeline The original type of data the pipeline must be fed (the input to the very first step). This type is preserved across the entire chain.
Input The local input type of the current node Current Node The type that the current step's function expects to receive from the immediately preceding node. This is the argument type for the __call__ method.
Output The local output type of the current node Current Node The type of data this specific node returns. This becomes the Input for the subsequent node or the output type for the entire pipeline.

Pipeline

A pipeline is the last Feeder in a chain of Feeders, due to the nature of chaining. To run the entire pipeline of Steps or other nodes, you must call the last node's .feed() method, as mentioned above. You will see many examples of this in the documentation.