redb.Tsak capabilities

redb.Tsak is the runtime host for redb.Route. It loads route packages into named route contexts, starts, stops and reloads them while the process runs, and exposes management over a REST API, a command line tool and a web dashboard. One worker can run every package, a set of workers can each run their own, and a cluster of workers shares the work through a redb database.

What it is and how it ships

  • Host process: redb.Tsak.Worker, a .NET generic host; services.AddTsak(configuration) and services.AddTsakCluster(configuration) register it.
  • Container images on ghcr.io/redbase-app: redb-tsak-worker (API, port 9090), redb-tsak-web (dashboard, port 8085), redb-tsak-stack (worker and dashboard in one container, ports 9090 and 8085).
  • Release archives: redb-tsak-<version>-linux-x64.tar.gz and redb-tsak-<version>-win-x64.zip.
  • Images and archives are signed with cosign; cosign.pub is a release asset.
  • NuGet packages: redb.Tsak.Core; redb.Tsak.Core.Pro, which adds the cluster; redb.Tsak.Contracts (DTOs); redb.Tsak.Client; redb.Tsak.CLI (a dotnet tool, command tsak); redb.Tsak.Templates.
  • Project template: dotnet new install redb.Tsak.Templates, then dotnet new tsak-worker with --db sqlite|postgres|mssql, --storage redb|inmemory, --pro true|false.
  • Compose files for the worker, web, stack and full (worker and web) layouts.
  • A Prometheus and Grafana dashboard under deploy/observability and deploy/grafana.

Route packages and their life cycle

A module is code or XML that builds routes; a package carries one or more modules and is loaded, replaced and removed while the worker runs.

  • Three module conventions:
    • a class implementing ITsakModule;
    • a type InitRoute with public static IRouteContext main(IRouteContext) or Task<IRouteContext> main(IRouteContext);
    • XML route artifacts listed in a package manifest (XmlRouteModule).
  • ITsakModule.InitializeAsync is awaited before the context starts, so a module can sync schemes or load reference data first.
  • Two deployment formats: bare DLLs in a module directory, or a .tpkg file (a ZIP with manifest.json, module DLLs and {Name}.config.json).
  • manifest.json fields: Name, Version, EntryPoints, Dependencies, Artifacts (*.route.xml), SchemaVersion, Resources, RequiredConfigKeys.
  • A key listed in RequiredConfigKeys and missing from configuration fails the module at start.
  • Module directories are set in Tsak:Modules:AssemblyPaths.
  • Packages are opened in dependency order (Dependencies); dependency cycles are reported.
  • Hot reload: the directories are rescanned every Tsak:HotReload:ScanIntervalSeconds (30 by default, 10 in the shipped appsettings).
  • A new, changed or removed package is loaded, swapped or stopped without a process restart.
  • AdditionStabilityScans: a .tpkg is opened only after its size and time stop changing.
  • RemovalDebounceScans: a delete followed by a copy is not taken for a removal.
  • A new version that fails to initialize or start is rolled back to the previous one.
  • KeepVersions previous versions are kept.
  • Module version format yyyy.MM.dd.HHmm (ModuleVersion), compared chronologically.
  • Remote deploy: POST /api/modules/upload, /validate, /{name}/rollback.
  • Remote deploy is off unless Tsak:Modules:Upload:Enabled=true; defaults MaxSizeMB 100, KeepVersions 3, RequireSignatureForUpload true.
  • Package signing: a detached {name}.tpkg.sig (RSA or ECDSA, SHA-256) is checked when a package is loaded, for uploads and for files dropped on disk.
  • Signing settings: Tsak:Modules:Signature:Required, PublicKeyPath or PublicKeyPem.
  • CLI for packages: tsak module keygen, sign, deploy, validate, rollback.
  • Deploy advice: GET /api/health/deploy answers 200 "hot-swap" or 409 "cold-deploy" for the node; /api/health/deploy/cluster answers for every alive node; tsak system deploy-advice [--cluster].
  • Deploy advice only advises; it does not change anything.
  • Limit: Tsak:HotReload:RollingUpdate is reserved and not implemented. Nodes reload independently on their own scan schedule; a warning is logged when the key is set.
  • Limit: Tsak:HotReload:StartupTimeoutSeconds is reserved. A module start has no time limit.

Contexts and modules

Every module runs in a route context; contexts are started, stopped and configured separately.

  • A module runs in a named context (modules listed in Tsak:Contexts:{name}:Modules, or a ContextName in {Module}.config.json) or in an anonymous context created for it.
  • Context configuration is merged from five layers, in order: Tsak:Contexts:default, Tsak:Contexts:{name}, context.json beside the module, {Module}.config.json (the one embedded in the package, then the one on disk), Tsak:Contexts:{name}:Override.
  • Tsak:Contexts:{name}:AutoStart, and Dependencies for the start order between contexts.
  • A manual stop or start of a context or of one route is remembered in the state store and applied at the next start.
  • Context operations: start, stop with graceful drain, restart, remove, reset route states (/api/contexts/*, tsak context ...).
  • Route operations: list, detail, start, stop with a drain timeout, force-stop, in-flight exchanges, metrics (/api/contexts/{ctx}/routes/*, tsak route ...).
  • Isolation: each package or module gets its own ModuleAssemblyLoadContext.
  • Assemblies are loaded from bytes, so module files are never locked.
  • Tsak:HotReload:Collectible=true unloads a replaced version from memory; the default, false, keeps old versions until the process restarts.
  • Limit: with Collectible=true, a module library that keeps a static cache of its own types, or Emit-generated code held outside the module context, can still keep the old version in memory. The hotreload health check turns Degraded above MaxOrphanedContexts.
  • Shared layer: assemblies in Tsak:HotReload:SharedPath (Libs/shared) load once for all contexts and are registered as components in each.
  • RestartContextsOnSharedChange restarts the contexts when a shared assembly changes.
  • Extension points: IStaticModuleProvider (modules compiled into the host), IContextCustomizer, ISystemContextPlugin (extra controllers on the API), ITsakLifecycleHook, IHealthContributor, IModuleHealthContributor.
  • A failing module never stops the node: it is reported in ModuleActivationReport, and the other contexts keep running.
  • The REST API itself runs as the _system route context; the API refuses to remove that context or to force-stop its routes.

redb instances

The worker keeps its own state in redb, and modules can use further named redb databases.

  • The worker's own redb: Tsak:Redb:Provider (postgres, mssql, sqlite) with ConnectionStrings:Postgres, MSSql or Sqlite.
  • Cache settings in Tsak:Redb:Cache; save strategy in Tsak:Redb:PropsSaveStrategy.
  • Tsak:Storage:Type: InMemory (state is lost on restart, API keys come from configuration) or Redb (module registry, state store and API keys in redb).
  • Named instances per context: Redb:{name} with Provider, ConnectionString, EnsureCreated and cache keys.
  • A route resolves a named instance with context.GetRedbService("name", exchange).
  • Only the instance named by RedbInstanceName runs the schema bootstrap at start; the others are registered without it.
  • A named instance whose database holds a newer schema, or whose schema lock is not released, is not registered; the redb health check names the context, the instance and the kind of failure.
  • sql: steps take dataSource=redb (the worker's redb) and dataSource=redb:<name> (a named instance).
  • With these data sources the statement runs on redb's connection for the exchange and commits or rolls back together with the redb steps of a .Transacted() block.
  • Limit: dataSource=redb does not work with outputType=StreamList, breakBatchOnError=false, the polling sql: consumer, or the SQL idempotent and claim-check repositories.
  • ITsakSaveInterceptors: a module subscribes redb save interceptors through its context, and they are removed with the context.
  • These interceptors see every save of the worker, not only the module's own.
  • Storage maintenance: GET /api/storage/instances, /stats, POST /api/storage/analyze; dashboard page Storage.
  • The worker registers the ADO.NET providers Npgsql, Microsoft.Data.SqlClient and Microsoft.Data.Sqlite, so an XML-only module names a provider without registering it.

Scheduler

Scheduled routes run on Quartz.

  • One Quartz scheduler per route context, created with the context's first cron: or qtimer: route.
  • Job keys are unique within a context.
  • Job store: RAMJobStore when there is no Quartz section.
  • AdoJobStore (Quartz:quartz.jobStore.type) on the worker's database; the connection string and driver delegate are taken from the redb settings, and the QRTZ_ tables are created at start.
  • Clustered job store on PostgreSQL and SQL Server (quartz.jobStore.clustered).
  • The scheduler name is scoped to the Tsak cluster name, so several clusters can share one database.
  • Limit: on SQLite the job store is always non-clustered.
  • Operator actions: status, scheduled jobs, running jobs, start, standby, pause job, resume job, fire job now (/api/scheduler/*, tsak scheduler ..., each with --context).
  • An operator's job pause is kept when the route starts again: the start applies the route's schedule and leaves the job paused (logged); resume it on the scheduler.
  • Where the pause lives: with AdoJobStore in the database, so it holds across a restart of the context, a module swap, a node restart and for every node of the cluster. With RAMJobStore it holds across a restart of the route inside a running context and is lost when the context stops (context restart, module swap, node restart), because the context's scheduler stops with its context.
  • Audit and dead-letter retention run as cron: routes of the _system context and are shown on the scheduler page.

Cluster

The cluster comes with the package redb.Tsak.Core.Pro. Nodes coordinate through a shared redb database.

  • Tsak:Cluster:Enabled turns it on.
  • Settings and defaults: ClusterName, GroupName, NodeId (default: the host name), ApiEndpoint, HeartbeatIntervalSeconds 15, DeadNodeTimeoutSeconds 60, LeaderLockTtlSeconds 30, Strategy round-robin or least-loaded, FailedRetryBackoffSeconds 60.
  • The node registry, the leader lock, module assignments and distributed locks are kept in redb.
  • The leader detects dead nodes and reassigns their modules; the other nodes start and stop modules by assignment.
  • Several clusters can share one database: every coordination record, dead-letter entry and audit row is scoped by ClusterName.
  • .Cluster(true) on a route keeps its consumer on one node at a time (ClusteredRoutePolicy, a TTL lock with epoch fencing).
  • .Cluster(true) is not applied to cron: and qtimer: routes: the clustered job store already fires them once.
  • Cordon: POST /api/cluster/nodes/{id}/cordon and uncordon, tsak cluster cordon. A cordoned node takes no new work and releases its route locks, so its routes move to other nodes.
  • Other operations: cluster status, nodes, rebalance, remove a node record (/api/cluster/*, tsak cluster status|nodes|rebalance).
  • IDistributedLock (a TTL lock; AcquireAsync with a wait timeout) is the lock service behind route clustering, registered in the host container in cluster mode.
  • Limit: a cluster needs a database every node reaches, PostgreSQL or SQL Server.
  • Limit: with Storage:Type=InMemory the suspended state of a route is lost on restart; a warning is printed.

Management: API, CLI, dashboard

  • REST API on Tsak:Api:Host (default 127.0.0.1) and Tsak:Api:Port (9090).
  • Tsak:Api:Enabled=false runs the worker without an API.
  • 17 controllers, 75 endpoints: /api/contexts, routes under /api/contexts/{ctx}/routes, /api/modules, /api/scheduler, /api/cluster, /api/system, /api/health, /api/logs, /api/audit, /api/exchanges, /api/watchdog, /api/diagnostics, /api/lifecycle, /api/dashboard, /api/storage, /api/auth, /api/users.
  • /api/system: health, metrics, metrics/history, info, config (merged, secrets redacted), assemblies.
  • Echo route system-echo on Tsak:Api:Echo:Path (/api/echo): no key needed, ships stopped.
  • Typed client: ITsakApiClient and TsakApiClient in redb.Tsak.Client.
  • CLI tsak, command groups: system, context, route, module, scheduler, cluster, log, audit, dlq, watchdog, diagnostics, auth, profile.
  • CLI global options: --profile/-p, --url/-u, --key/-k, --output/-o (table, JSON, quiet), --no-color, --yes/-y, --watch, --interval, --timeout.
  • Saved connection profiles: tsak profile add|use|list|remove.
  • Dashboard redb.Tsak.Web (Blazor Server), pages: Dashboard, Cluster, node detail, Routes and route view, Endpoints, Logs, Watchdog, Dead letters, Audit, Storage, Auth & Users (API keys and user accounts), About.
  • Dashboard modes (Tsak:Web:Mode): standalone, with nodes from Tsak:Web:Nodes or Tsak:Web:StandaloneUrl; cluster, with nodes read from the cluster registry in redb and the key Tsak:Web:ServiceApiKey.

Dead letters, replay, audit

  • Dead-letter store tsak_dlq: a failed exchange is captured at the route's last .Replayable("...") checkpoint when no OnException handled the failure.
  • To("tsak-dlq:") inside an OnException sends the exchange to the dead-letter store explicitly.
  • Replay and discard: GET /api/exchanges/failed, POST /api/exchanges/{id}/replay, DELETE /api/exchanges/{id}; tsak dlq list|replay|discard.
  • Settings: Tsak:Dlq:Enabled, Tsak:Dlq:RetentionDays (30).
  • Limit: a route without a .Replayable checkpoint before the failing step captures nothing; a warning names the route.
  • Admin audit trail tsak_audit_log: state-changing API calls marked [AuditAdminAction] are written with actor, action and target.
  • Audit access: GET /api/audit, tsak audit; settings Tsak:Audit:Enabled, Tsak:Audit:RetentionDays (90).
  • Without a database the audit goes to the log.
  • Lifecycle events of contexts and routes: GET /api/lifecycle, tsak diagnostics lifecycle.

Health, metrics, logs, traces

  • Probes without authentication: GET /api/health/startup, /live, /ready (200 or 503).
  • Tsak:Health:DegradedNotReady=true makes a Degraded state fail readiness.
  • Aggregate GET /api/system/health with named checks: contexts, routes, metrics, watchdog, control-plane, redb, hotreload, cluster, and module:{name} from IModuleHealthContributor.
  • Liveness fails while the watchdog sees hung exchanges.
  • Watchdog (Tsak:Watchdog): CheckIntervalSeconds 15, SuspectedThresholdMinutes 5, HungThresholdMinutes 30, AutoRestartHungRoutes false, AutoRestartTimeoutSeconds 60.
  • The watchdog is enabled and disabled at run time (/api/watchdog/*, tsak watchdog).
  • Watchdog alerts (Tsak:Watchdog:Alerts, all off by default): Webhook, Telegram, Email (SMTP), Endpoint (any redb.Route producer URI); MinLevel, DedupWindowMinutes; POST /api/watchdog/test-alert sends a test alert.
  • Metrics: process and per-route metrics with in-memory history (Tsak:Metrics:CollectionIntervalSeconds 10, HistoryHours 12); GET /api/system/metrics, /metrics/history, and /metrics per route.
  • Prometheus: Tsak:Metrics:Prometheus:Enabled serves /metrics on the API port (internal listener on loopback, Port 9464).
  • Prometheus settings: RequireAuth, and AdditionalMeters, AdditionalSources for the meters of hosted modules.
  • Tracing: OpenTelemetry spans for routes and steps, exported over OTLP (Tsak:Tracing:Otlp:Enabled, Endpoint, Protocol grpc or http/protobuf, Tsak:Tracing:ServiceName).
  • Logs: Serilog, configured from the Serilog section.
  • In-memory log buffer (Tsak:Logs:BufferSize 2000), read by GET /api/logs and tsak log get --level --limit.
  • Log files are listed and downloaded through /api/logs/files.
  • Diagnostics: GET /api/diagnostics/dump and /api/diagnostics/{context}/{route}; tsak diagnostics dump|route|dashboard.

Security and sign-in

  • API keys: Authorization: Bearer <key> or X-Api-Key.
  • Keys are stored as HMAC-SHA256 hashes (Tsak:Auth:Secret), compared in constant time, with expiry and revocation.
  • Tsak:Auth:Enabled (default false).
  • Key stores: configuration (Tsak:Auth:Keys) with in-memory storage, or redb with Storage:Type=Redb.
  • Key management: POST/GET/DELETE /api/auth/keys, tsak auth create|list|revoke.
  • Roles viewer < operator < admin (TsakRoles, [RequiresRole]): GET needs viewer, other methods need operator, unless an action says otherwise.
  • Admin is needed for key and user management, module upload and removal, force-stop, the configuration dump and cluster record changes.
  • Custom role names match exactly.
  • Settings: Tsak:Auth:EnforceRoles (true), Tsak:Auth:RolelessKeysAreAdmin (false), Tsak:Auth:CacheTtlSeconds (300), Tsak:Auth:RevocationCheckSeconds (30).
  • Failed-key throttle per client address: Tsak:Api:AuthThrottle:Limit 10, WindowSeconds 60, LockoutSeconds 120.
  • Tsak:Api:AuthExempt (default /api/health/*); Tsak:Http:TrustedProxies (addresses or CIDRs).
  • An API reachable beyond loopback with authentication off is logged as a security warning at start.
  • Dashboard sign-in: a cookie session (tsak.auth, 8 hours sliding, the account re-checked every 5 minutes), antiforgery, and a login lockout (Tsak:Web:Lockout:MaxAttempts 5, WindowSeconds 300, DurationSeconds 60); Tsak:Web:TrustProxyHeaders.
  • Dashboard accounts in standalone mode: one administrator from Tsak:Web:AdminLogin with AdminPasswordHash (BCrypt) or AdminPassword.
  • Dashboard accounts in cluster mode: redb users (/api/users, with a seeded administrator).
  • redb.Identity runs as a Tsak module with its own named redb instance (Identity:RedbInstanceName), its own health entry and its own meters.
  • Limit: the dashboard and the management API do not sign in through OpenID Connect. The API takes API keys, the dashboard its own accounts.

Configuration sections

  • Under Tsak: Tsak:Api (with Echo, AuthExempt, AuthThrottle), Tsak:Auth, Tsak:Http:TrustedProxies, Tsak:Storage, Tsak:Redb (with Cache), Tsak:Modules (AssemblyPaths, Upload, Signature), Tsak:Contexts, Tsak:HotReload, Tsak:Cluster, Tsak:Metrics (with Prometheus), Tsak:Tracing, Tsak:Logs, Tsak:Watchdog (with Alerts), Tsak:Health, Tsak:Audit, Tsak:Dlq, Tsak:Web.
  • Outside Tsak: ConnectionStrings, Quartz (Quartz property names as keys), Serilog, RedbRoute (engine options applied to every module context, ShutdownTimeout among them).
  • Every key can be set by an environment variable, for example Tsak__Cluster__Enabled.

Kubernetes

  • Example manifests in deploy/k8s: deployment.yaml, service.yaml, servicemonitor.yaml.
  • The three probes map to startupProbe, livenessProbe and readinessProbe on /api/health/startup, /live and /ready.
  • Graceful stop on SIGTERM: lifecycle hooks run (the node leaves the cluster), then contexts are stopped one after another, each draining in-flight exchanges for up to RedbRoute:ShutdownTimeout.
  • terminationGracePeriodSeconds must cover the sum of those drain times.
  • Pod identity in a cluster: Tsak__Cluster__ApiEndpoint from the pod IP.
  • Metrics are scraped through /metrics on the API port.
  • Limit: plain manifests only; Tsak does not create or scale pods itself.

Platforms

  • Libraries target .NET 10 and .NET 11; the worker, the dashboard and the images run on .NET 10.
  • Databases: PostgreSQL, SQL Server, SQLite.
  • SQLite is the default of the template and of the image, and runs a single node only.

Sources and documentation: github.com/redbase-app/redb-tsak, redbase.app.