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).

Page Description
TrainBus ITrainBus interface: RunAsync, InitializeTrain
AddMediator Registration and assembly scanning configuration
TrainDiscovery ITrainDiscoveryService: discover registered trains and their input/output types
TrainExecution ITrainExecutionService: queue or run trains programmatically with JSON input
Concurrency Limiting Per-train and global concurrency limits for RUN executions

Table of contents


Back to top

Trax - A .NET framework for Railway Oriented Programming with Effects, Scheduling, and more