TraxRemote
Sends a train's queued runs to a remote worker instead of the scheduler host's local workers, without naming it in the scheduler's routing.
Signature
namespace Trax.Effect.Attributes;
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class TraxRemoteAttribute : Attribute
{
public TraxRemoteAttribute();
}Place it on the concrete train class (or a base class). It is not read from an interface.
Routing
The scheduler picks a train's job submitter in this order:
- A
ForTrain<T>()route on a UseRemoteWorkers, UseSqsWorkers or UseLambdaWorkers call. [TraxRemote]: the first of those calls in the builder, of whatever kind.- The default local submitter.
A scheduler with a [TraxRemote] train and none of those three calls fails when it is built, naming each such train. A train marked remote, often to keep it off the scheduler host, does not quietly fall back to running there.
The attribute routes queued work, which is what the scheduler dispatches. A direct run (run* mutations, ITrainExecutionService.RunAsync) goes through the IRunExecutor instead; see UseRemoteRun.
Example
using Trax.Effect.Attributes;
[TraxRemote]
public class RenderReportTrain : ServiceTrain<RenderReportInput, Unit>, IRenderReportTrain
{
protected override Task<Either<Exception, Unit>> Junctions() =>
Chain<RenderPdf>().Chain<UploadPdf>().Resolve();
}
services.AddTrax(trax => trax
.AddEffects(effects => effects.UsePostgres(connectionString))
.AddMediator(typeof(Program).Assembly)
.AddScheduler(scheduler => scheduler
.UseRemoteWorkers(remote => remote.BaseUrl = "https://workers.internal/trax/execute")));See Remote Execution for the worker side.
Package
dotnet add package Trax.Effect