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)andservices.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.gzandredb-tsak-<version>-win-x64.zip. - Images and archives are signed with cosign;
cosign.pubis 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, commandtsak);redb.Tsak.Templates. - Project template:
dotnet new install redb.Tsak.Templates, thendotnet new tsak-workerwith--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/observabilityanddeploy/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
InitRoutewithpublic static IRouteContext main(IRouteContext)orTask<IRouteContext> main(IRouteContext); - XML route artifacts listed in a package manifest (
XmlRouteModule).
- a class implementing
ITsakModule.InitializeAsyncis 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
.tpkgfile (a ZIP withmanifest.json, module DLLs and{Name}.config.json). manifest.jsonfields:Name,Version,EntryPoints,Dependencies,Artifacts(*.route.xml),SchemaVersion,Resources,RequiredConfigKeys.- A key listed in
RequiredConfigKeysand 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.tpkgis 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.
KeepVersionsprevious 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; defaultsMaxSizeMB100,KeepVersions3,RequireSignatureForUploadtrue. - 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,PublicKeyPathorPublicKeyPem. - CLI for packages:
tsak module keygen,sign,deploy,validate,rollback. - Deploy advice:
GET /api/health/deployanswers 200 "hot-swap" or 409 "cold-deploy" for the node;/api/health/deploy/clusteranswers for every alive node;tsak system deploy-advice [--cluster]. - Deploy advice only advises; it does not change anything.
- Limit:
Tsak:HotReload:RollingUpdateis reserved and not implemented. Nodes reload independently on their own scan schedule; a warning is logged when the key is set. - Limit:
Tsak:HotReload:StartupTimeoutSecondsis 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 aContextNamein{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.jsonbeside the module,{Module}.config.json(the one embedded in the package, then the one on disk),Tsak:Contexts:{name}:Override. Tsak:Contexts:{name}:AutoStart, andDependenciesfor 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=trueunloads 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. Thehotreloadhealth check turns Degraded aboveMaxOrphanedContexts. - Shared layer: assemblies in
Tsak:HotReload:SharedPath(Libs/shared) load once for all contexts and are registered as components in each. RestartContextsOnSharedChangerestarts 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
_systemroute 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) withConnectionStrings:Postgres,MSSqlorSqlite. - Cache settings in
Tsak:Redb:Cache; save strategy inTsak:Redb:PropsSaveStrategy. Tsak:Storage:Type:InMemory(state is lost on restart, API keys come from configuration) orRedb(module registry, state store and API keys in redb).- Named instances per context:
Redb:{name}withProvider,ConnectionString,EnsureCreatedand cache keys. - A route resolves a named instance with
context.GetRedbService("name", exchange). - Only the instance named by
RedbInstanceNameruns 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
redbhealth check names the context, the instance and the kind of failure. sql:steps takedataSource=redb(the worker's redb) anddataSource=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=redbdoes not work withoutputType=StreamList,breakBatchOnError=false, the pollingsql: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.SqlClientandMicrosoft.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:orqtimer:route. - Job keys are unique within a context.
- Job store:
RAMJobStorewhen there is noQuartzsection. AdoJobStore(Quartz:quartz.jobStore.type) on the worker's database; the connection string and driver delegate are taken from the redb settings, and theQRTZ_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
AdoJobStorein the database, so it holds across a restart of the context, a module swap, a node restart and for every node of the cluster. WithRAMJobStoreit 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_systemcontext 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:Enabledturns it on.- Settings and defaults:
ClusterName,GroupName,NodeId(default: the host name),ApiEndpoint,HeartbeatIntervalSeconds15,DeadNodeTimeoutSeconds60,LeaderLockTtlSeconds30,Strategyround-robinorleast-loaded,FailedRetryBackoffSeconds60. - 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 tocron:andqtimer:routes: the clustered job store already fires them once.- Cordon:
POST /api/cluster/nodes/{id}/cordonanduncordon,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;AcquireAsyncwith 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=InMemorythe suspended state of a route is lost on restart; a warning is printed.
Management: API, CLI, dashboard
- REST API on
Tsak:Api:Host(default127.0.0.1) andTsak:Api:Port(9090). Tsak:Api:Enabled=falseruns 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-echoonTsak:Api:Echo:Path(/api/echo): no key needed, ships stopped. - Typed client:
ITsakApiClientandTsakApiClientinredb.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 fromTsak:Web:NodesorTsak:Web:StandaloneUrl;cluster, with nodes read from the cluster registry in redb and the keyTsak:Web:ServiceApiKey.
Dead letters, replay, audit
- Dead-letter store
tsak_dlq: a failed exchange is captured at the route's last.Replayable("...")checkpoint when noOnExceptionhandled the failure. To("tsak-dlq:")inside anOnExceptionsends 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
.Replayablecheckpoint 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; settingsTsak: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=truemakes a Degraded state fail readiness.- Aggregate
GET /api/system/healthwith named checks:contexts,routes,metrics,watchdog,control-plane,redb,hotreload,cluster, andmodule:{name}fromIModuleHealthContributor. - Liveness fails while the watchdog sees hung exchanges.
- Watchdog (
Tsak:Watchdog):CheckIntervalSeconds15,SuspectedThresholdMinutes5,HungThresholdMinutes30,AutoRestartHungRoutesfalse,AutoRestartTimeoutSeconds60. - 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-alertsends a test alert. - Metrics: process and per-route metrics with in-memory history (
Tsak:Metrics:CollectionIntervalSeconds10,HistoryHours12);GET /api/system/metrics,/metrics/history, and/metricsper route. - Prometheus:
Tsak:Metrics:Prometheus:Enabledserves/metricson the API port (internal listener on loopback,Port9464). - Prometheus settings:
RequireAuth, andAdditionalMeters,AdditionalSourcesfor the meters of hosted modules. - Tracing: OpenTelemetry spans for routes and steps, exported over OTLP (
Tsak:Tracing:Otlp:Enabled,Endpoint,Protocolgrpc or http/protobuf,Tsak:Tracing:ServiceName). - Logs: Serilog, configured from the
Serilogsection. - In-memory log buffer (
Tsak:Logs:BufferSize2000), read byGET /api/logsandtsak log get --level --limit. - Log files are listed and downloaded through
/api/logs/files. - Diagnostics:
GET /api/diagnostics/dumpand/api/diagnostics/{context}/{route};tsak diagnostics dump|route|dashboard.
Security and sign-in
- API keys:
Authorization: Bearer <key>orX-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 withStorage: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:Limit10,WindowSeconds60,LockoutSeconds120. 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:MaxAttempts5,WindowSeconds300,DurationSeconds60);Tsak:Web:TrustProxyHeaders. - Dashboard accounts in standalone mode: one administrator from
Tsak:Web:AdminLoginwithAdminPasswordHash(BCrypt) orAdminPassword. - 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(withEcho,AuthExempt,AuthThrottle),Tsak:Auth,Tsak:Http:TrustedProxies,Tsak:Storage,Tsak:Redb(withCache),Tsak:Modules(AssemblyPaths,Upload,Signature),Tsak:Contexts,Tsak:HotReload,Tsak:Cluster,Tsak:Metrics(withPrometheus),Tsak:Tracing,Tsak:Logs,Tsak:Watchdog(withAlerts),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,ShutdownTimeoutamong 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,livenessProbeandreadinessProbeon/api/health/startup,/liveand/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. terminationGracePeriodSecondsmust cover the sum of those drain times.- Pod identity in a cluster:
Tsak__Cluster__ApiEndpointfrom the pod IP. - Metrics are scraped through
/metricson 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.