Reference

MediatorConfiguration

Package Trax.MediatorNamespace Trax.Mediator.ConfigurationSource MediatorConfiguration.cs

The settings AddMediator resolved from its builder, registered as a singleton. Every setter is internal: the builder is the only way to change a value.

Signature

namespace Trax.Mediator.Configuration;
 
public class MediatorConfiguration
{
    public ServiceLifetime TrainLifetime { get; }
    public Assembly[] Assemblies { get; }
    public int? GlobalMaxConcurrentRun { get; }
    public int? PerPrincipalMaxConcurrentRun { get; }
    public int MaxInputJsonBytes { get; }
    public TimeSpan MaxQueueHookDuration { get; }
    public bool AllowMissingAuthorizationService { get; }
    public bool SkipChainVerification { get; }
}

Properties

PropertyDefaultSet withDescription
TrainLifetimeTransientTrainLifetime(ServiceLifetime)The lifetime discovered trains are registered with. Singleton is refused
AssembliesemptyScanAssemblies(...)The assemblies scanned for IServiceTrain<,> implementations, including any an earlier subsystem contributed (such as AddStateMachines)
GlobalMaxConcurrentRunnull (no limit)GlobalConcurrentRunLimit(int)Concurrent direct runs across every train
PerPrincipalMaxConcurrentRunnull (no limit)PerPrincipalMaxConcurrentRun(int)Concurrent direct runs per principal. Holds nothing until an ICurrentPrincipalProvider that returns ids is registered
MaxInputJsonBytes262144 (256 KiB)WithMaxInputJsonBytes(int)The UTF-8 size cap on caller-supplied input JSON for RunAsync and QueueAsync, checked after authorization and before deserialization. A queued entry's stored, re-serialized input has its own, larger cap derived from this one
MaxQueueHookDuration30 secondsWithMaxQueueHookDuration(TimeSpan)How long an OnQueue hook may run while its enqueue holds a connection and a transaction. Past it the enqueue fails with QueueHookTimeoutException and rolls back. Timeout.InfiniteTimeSpan removes the limit
AllowMissingAuthorizationServicefalseAllowMissingAuthorizationService()Lets a host with [TraxAuthorize] trains start without an ITrainAuthorizationService, for scheduler-only or dashboard-only processes
SkipChainVerificationfalseSkipChainVerification()Skips the startup check that reads every registered train's chain

Behavior

Per-train limits from ConcurrentRunLimit<TTrain>(int) are kept internally and are not exposed here. AddServiceTrainBus called on its own registers an instance with the defaults when none is registered.

Example

var configuration = serviceProvider.GetRequiredService<MediatorConfiguration>();
 
Console.WriteLine($"Input cap: {configuration.MaxInputJsonBytes} bytes");

See also