Train Methods

Methods available on Train<TInput, TReturn> for composing junctions. These are the core building blocks of every Trax train pipeline.

A typical train overrides Junctions() and calls chain methods directly:

protected override Task<Either<Exception, OrderResult>> Junctions() =>
        Chain<ValidateOrder>()              // Execute junction, auto-wiring input/output via Memory
        .Chain<ProcessPayment>()
        .Chain<SendConfirmation>().Resolve();     // Final result extracted from Memory automatically

For advanced cases (custom logic, async setup, manual Either construction), override RunInternal instead:

protected override async Task<Either<Exception, OrderResult>> RunInternal(OrderInput input) =>
    Activate(input)
        .Chain<ValidateOrder>()
        .Chain<ProcessPayment>()
        .Chain<SendConfirmation>()
        .Resolve();
MethodDescription
JunctionsOverride to define the train's route, the primary way to compose junctions
ChainExecutes a junction, wiring its input from Memory and storing its output back
ShortCircuitExecutes a junction that can return early, bypassing remaining junctions
ExtractPulls a nested property/field out of a Memory object into its own Memory slot
AddServicesStores DI services into Memory so junctions can access them
ActivateStores the train input into Memory (used in RunInternal path)
ResolveExtracts the final TReturn result from Memory (used in RunInternal path)
Run / RunEitherExecutes the train from the outside. Run throws on failure, RunEither returns Either