Reference

DeployManifest

Package Trax.EffectNamespace Trax.Effect.Configuration.DeploySource DeployManifest.cs, DeployDatabase.cs, DeployEndpoints.cs, DeployAuthenticationScheme.cs, TraxDeployExport.cs, DeployFact.cs, IDeployManifestSource.cs, DeployExportServeGate.cs

What a host needs from where it is deployed, as it reports it when started with --trax-export-deploy <path>: its roles, its database, the transports it connects to, the endpoints a load balancer routes to, and the authentication schemes it registers. trax deploy reads it, so the infrastructure it builds follows the host's code.

Signatures

public static class TraxDeployExport
{
    public const string Argument = "--trax-export-deploy";
    public static string? Path { get; }
    public static bool Requested { get; }
    public static string? PathIn(IReadOnlyList<string> args);
}
 
public sealed class DeployManifest
{
    public const int CurrentVersion = 1;
    public const string SecretSourcesSection = "Trax:Deploy:SecretSources";
    public int Version { get; set; }
    public List<string> Roles { get; set; }
    public DeployDatabase? Database { get; set; }
    public List<string> Transports { get; set; }
    public DeployEndpoints Endpoints { get; set; }
    public List<DeployAuthenticationScheme> Authentication { get; set; }
    public List<string> SecretSources { get; set; }
    public string Write();
    public static DeployManifest Read(string json);
}

Properties

PropertyWhat it holds
VersionThe format version, 1. Read refuses a newer one.
RolesSorted: api when the host maps the Trax GraphQL endpoint with UseTraxGraphQL, job-runner when it maps a runner endpoint with UseTraxJobRunner or UseTraxRunEndpoint, scheduler for AddScheduler, worker for AddTraxWorker.
DatabaseDeployDatabase: Provider is postgres, sqlite or in-memory; MigratesOnStart is false when the code calls SkipMigrations(). Null with no data provider.
TransportsSorted: rabbitmq when the host broadcasts through RabbitMQ (UseRabbitMq) or its persisted operations invalidate their caches through it (UseRabbitMqInvalidation).
EndpointsDeployEndpoints: the paths of GraphQL (UseTraxGraphQL), Health (MapHealthChecks) and Console (UseTraxApiDashboard), each null when not mapped.
AuthenticationDeployAuthenticationScheme per registered scheme, sorted by Name, with its Handler type name (JwtBearerHandler, OpenIdConnectHandler, ...).
SecretSourcesSorted: where the host reads secrets from at start besides its environment. aws-secrets when it calls AddTraxAwsSecretsAsync. A reader marks itself with Trax:Deploy:SecretSources:<name> = true in the host's configuration (SecretSourcesSection). A Kubernetes environment on EKS refuses a host without aws-secrets, since that is the only way its secrets reach it.

Behavior

RunTraxAsync, on a WebApplication or any IHost, writes the manifest and returns without starting the host when the process was started with --trax-export-deploy <path>. It first runs every startup check the host registers, the same ones the client export runs, so a host that would refuse to start (demo credentials outside Development, an operations namespace with no gate) refuses the export too and writes nothing. UsePostgres and UseSqlite open no database in an exporting process, and one that calls app.Run() instead of RunTraxAsync refuses to start.

TraxDeployExport.Path is the path after the argument on this process's command line, Requested whether there is one, and PathIn(args) the same for any arguments. The argument without a path throws ArgumentException.

Example

dotnet Orders.dll --trax-export-deploy deploy.json
{
  "version": 1,
  "roles": ["api", "scheduler"],
  "database": { "provider": "postgres", "migratesOnStart": true },
  "transports": [],
  "endpoints": { "graphQL": "/trax/graphql", "health": "/trax/health" },
  "authentication": [{ "name": "Bearer", "handler": "JwtBearerHandler" }],
  "secretSources": []
}

See also