Mediator API

The mediator pattern in Trax.Mediator routes train execution by input type. Instead of injecting specific train interfaces, you inject ITrainBus and dispatch by passing the input object — the bus discovers and runs the correct train automatically.

// Instead of:
var result = await _createOrderTrain.Run(orderInput);
 
// You can:
var result = await _trainBus.RunAsync<OrderResult>(orderInput);

This decouples callers from specific train implementations and enables train composition (nested trains that participate in the same metadata chain).

PageDescription
TrainBusITrainBus interface — RunAsync, InitializeTrain
AddMediatorRegistration and assembly scanning configuration
TrainDiscoveryITrainDiscoveryService — discover registered trains and their input/output types
TrainExecutionITrainExecutionService — queue or run trains programmatically with JSON input
Concurrency LimitingPer-train and global concurrency limits for RUN executions