Trains and Junctions

The types you derive from and register: the train and junction base classes, the contracts they implement, the exception a failure carries, and the helpers that put them in the container. The methods you call inside Junctions() are under Train Methods.

public interface ICreateOrderTrain : IServiceTrain<CreateOrderInput, OrderResult>;
 
public class CreateOrderTrain : ServiceTrain<CreateOrderInput, OrderResult>, ICreateOrderTrain
{
    protected override Task<Either<Exception, OrderResult>> Junctions() =>
        Chain<ValidateOrder>().Chain<ChargePayment>().Chain<PersistOrder>().Resolve();
}
 
public class ChargePayment(IPaymentGateway gateway) : EffectJunction<ValidatedOrder, PaymentReceipt>
{
    public override Task<PaymentReceipt> Run(ValidatedOrder order) =>
        gateway.Charge(order.CustomerId, order.Total, CancellationToken);
}
PagePackageDescription
TrainTrax.CoreTrain<TInput, TReturn>: the base class, with Run, RunEither, ExternalId and the chain methods
ServiceTrainTrax.EffectServiceTrain<TIn, TOut> and IServiceTrain<TIn, TOut>: metadata, effects, lifecycle hooks, container-built junctions
JunctionTrax.CoreJunction<TIn, TOut> and IJunction<TIn, TOut>: one unit of work on the railway
EffectJunctionTrax.EffectEffectJunction<TIn, TOut>: a junction the junction effects can observe
IRouteTrax.CoreIRoute<TIn, TOut>: the one-method contract every train implements
MonadTaskTrax.CoreMonadTask<TInput, TReturn>: the awaitable link a chain step returns
TrainExceptionTrax.CoreTrainException, TrainExceptionData and FailureClass: how a failure is raised and recorded
Route and Junction RegistrationTrax.EffectAddScopedTraxRoute, AddTransientTraxRoute, AddSingletonTraxRoute and the *TraxJunction aliases