Bundle: redb-tsak / src/redb.Tsak.Worker (src.redb.Tsak.Worker.txt), 8 files Snapshot: development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Index: https://redbase.app/src/dev-2026-12-06/redb-tsak/_index.txt ==== Path: redb-tsak/src/redb.Tsak.Worker/Dockerfile Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/Dockerfile ---- # Build context: repository root (parent of redb.Tsak, redb.DB, redb.Route, etc.) FROM mcr.microsoft.com/dotnet/runtime:9.0 AS base WORKDIR /app EXPOSE 9090 FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src # Copy csproj files for restore COPY redb.DB/src/redb.Core/redb.Core.csproj redb.DB/src/redb.Core/ COPY redb.DB/src/redb.Core.Pro/redb.Core.Pro.csproj redb.DB/src/redb.Core.Pro/ COPY redb.DB/src/redb.Postgres/redb.Postgres.csproj redb.DB/src/redb.Postgres/ COPY redb.DB/src/redb.Postgres.Pro/redb.Postgres.Pro.csproj redb.DB/src/redb.Postgres.Pro/ COPY redb.DB/src/redb.MSSql/redb.MSSql.csproj redb.DB/src/redb.MSSql/ COPY redb.DB/src/redb.MSSql.Pro/redb.MSSql.Pro.csproj redb.DB/src/redb.MSSql.Pro/ COPY redb.Route/src/redb.Route.Core/redb.Route.Core.csproj redb.Route/src/redb.Route.Core/ COPY redb.Route/src/redb.Route.Http/redb.Route.Http.csproj redb.Route/src/redb.Route.Http/ COPY redb.Route/src/redb.Route.Quartz/redb.Route.Quartz.csproj redb.Route/src/redb.Route.Quartz/ COPY redb.Tsak/src/redb.Tsak.Core/redb.Tsak.Core.csproj redb.Tsak/src/redb.Tsak.Core/ COPY redb.Tsak/src/redb.Tsak.Worker/redb.Tsak.Worker.csproj redb.Tsak/src/redb.Tsak.Worker/ COPY redb.Tsak/Directory.Build.props redb.Tsak/ RUN dotnet restore redb.Tsak/src/redb.Tsak.Worker/redb.Tsak.Worker.csproj # Copy everything and build COPY redb.DB/src/redb.Core/ redb.DB/src/redb.Core/ COPY redb.DB/src/redb.Core.Pro/ redb.DB/src/redb.Core.Pro/ COPY redb.DB/src/redb.Postgres/ redb.DB/src/redb.Postgres/ COPY redb.DB/src/redb.Postgres.Pro/ redb.DB/src/redb.Postgres.Pro/ COPY redb.DB/src/redb.MSSql/ redb.DB/src/redb.MSSql/ COPY redb.DB/src/redb.MSSql.Pro/ redb.DB/src/redb.MSSql.Pro/ COPY redb.Route/src/ redb.Route/src/ COPY redb.Tsak/src/ redb.Tsak/src/ COPY redb.Tsak/Directory.Build.props redb.Tsak/ WORKDIR /src/redb.Tsak/src/redb.Tsak.Worker RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app COPY --from=publish /app/publish . ENTRYPOINT ["dotnet", "redb.Tsak.Worker.dll"] Path: redb-tsak/src/redb.Tsak.Worker/Program.cs Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/Program.cs ---- using redb.Tsak.Core.Extensions; using redb.Tsak.Core.Pro.Extensions; using redb.Tsak.Worker; using redb.Tsak.Worker.Utils; using redb.Tsak.Core.Monitoring; using Serilog; // FIRST statement of the process: install the shared-layer resolver and preload the redb.* // framework BEFORE any redb.* type is touched. Keep this above everything else. See // SharedRuntimeBootstrap. SharedRuntimeBootstrap.InstallEarly(); StartupBanner.Print(); var builder = Host.CreateDefaultBuilder(args) .UseSerilog((context, services, configuration) => configuration .ReadFrom.Configuration(context.Configuration) .Enrich.With(new redb.Tsak.Worker.Utils.MemoryUsageEnricher()) .WriteTo.Sink(services.GetRequiredService())) .ConfigureServices((context, services) => { services.AddTsak(context.Configuration); services.AddTsakCluster(context.Configuration); }); await builder.Build().RunAsync(); Path: redb-tsak/src/redb.Tsak.Worker/README.md Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/README.md ---- # redb.Tsak.Worker .NET Worker Service that hosts and orchestrates **redb.Tsak** modules — route-based integration pipelines built on top of [redb.Route](https://github.com/redberriespro/redb.Route). The worker manages module lifecycle, execution contexts, hot-reload, health monitoring, and exposes a REST API for management by the [Web dashboard](../redb.Tsak.Web/README.md) or external tooling. ## Quick Start ```bash dotnet run --project src/redb.Tsak.Worker ``` Default API endpoint: `http://0.0.0.0:9090` --- ## Configuration Reference All settings are in `appsettings.json`. Sections are listed below with their actual defaults from code. ### `Tsak:Storage` — Storage Backend Controls where module definitions and runtime state are persisted. | Key | Type | Default | Description | |-----|------|---------|-------------| | `Type` | `string` | `"InMemory"` | `"InMemory"` — volatile, config-only. `"Redb"` — persistent via redb store. | - **InMemory**: API keys are read-only from `Tsak:Auth:Keys` config. Module and state data is lost on restart. - **Redb**: Requires `ConnectionStrings` and `Tsak:Redb` to be configured. API keys are seeded from config and can be managed at runtime. ### `Tsak:Redb` — Database Configuration Required when `Storage:Type = "Redb"` or `Cluster:Enabled = true`. | Key | Type | Default | Description | |-----|------|---------|-------------| | `Provider` | `string` | — | `"postgres"` or `"mssql"`. | | `UsePro` | `bool` | `false` | Enable redb.Core.Pro features (props change tracking, clustering). Pro is free of charge and needs no key. | | `PropsSaveStrategy` | `string` | `"DeleteInsert"` | Props write strategy: `"DeleteInsert"` or `"ChangeTracking"`. | Connection string is selected automatically based on `Provider`: - `ConnectionStrings:Postgres` for `"postgres"` - `ConnectionStrings:MSSql` for `"mssql"` ### `Tsak:Api` — Built-in REST API The worker runs an embedded HTTP server for management, metrics, and log access. | Key | Type | Default | Description | |-----|------|---------|-------------| | `Enabled` | `bool` | `true` | Enable the REST API. | | `Host` | `string` | `"0.0.0.0"` | HTTP listener bind address. | | `Port` | `int` | `9090` | HTTP listener port. | Endpoints include `/api/health`, `/api/contexts`, `/api/modules`, `/api/routes`, `/api/metrics`, `/api/logs/tail`, and more. ### `Tsak:Auth` — API Authentication | Key | Type | Default | Description | |-----|------|---------|-------------| | `Enabled` | `bool` | `false` | Require API key for management endpoints. Health endpoints are always open. | | `Secret` | `string` | — | JWT signing secret (min 16 characters). | | `Keys` | `array` | `[]` | Pre-configured API keys. | Each key in the `Keys` array: | Key | Type | Description | |-----|------|-------------| | `Id` | `string` | Unique key identifier. | | `KeyHash` | `string` | SHA-256 hash of the API key (uppercase hex). | | `Name` | `string` | Human-readable label. | | `Roles` | `string` | Comma-separated roles (e.g. `"admin"`). | | `UserId` | `string?` | Optional user association. | Clients authenticate with the `Authorization: Bearer ` header. The worker hashes it and matches against `KeyHash`. ### `Tsak:Modules` — Module Discovery | Key | Type | Default | Description | |-----|------|---------|-------------| | `AssemblyPaths` | `string[]` | `[]` | Directories scanned for module DLLs on startup and during hot-reload. | Modules are .NET assemblies implementing `ITsakModule`. Place compiled DLLs in the configured directories. ### `Tsak:Contexts` — Execution Environments Contexts group modules into isolated `RouteContext` instances with independent lifecycle. Configuration uses a 5-layer merge strategy (each layer overrides the previous): 1. `Tsak:Contexts:default` — base settings applied to all contexts 2. `Tsak:Contexts:{name}` — named context overrides 3. `context.json` — bundled inside module assemblies 4. `{Module}.config.json` — per-module config files 5. `Tsak:Contexts:{name}:Override` — DevOps final word (always wins) Per-context keys: | Key | Type | Default | Description | |-----|------|---------|-------------| | `AutoStart` | `bool` | `false` | Start context automatically when worker starts. | | `Modules` | `string[]` | `[]` | Module names assigned to this context. | | `Dependencies` | `string[]` | `[]` | Other contexts that must start first. The worker adds the contexts of the modules and packages the modules depend on (`ITsakModule.Dependencies`, the `Dependencies` of a package manifest). | Any additional keys become custom context properties accessible by modules at runtime. **Example:** ```jsonc "Contexts": { "default": { "AutoStart": true }, "api": { "AutoStart": true, "Modules": ["ApiModule"], "Dependencies": ["default"] } } ``` ### `Tsak:HotReload` — Dynamic Module Updates | Key | Type | Default | Description | |-----|------|---------|-------------| | `Enabled` | `bool` | `true` | Enable periodic filesystem scanning for new/updated DLLs. | | `ScanIntervalSeconds` | `int` | `30` | Polling interval for module directory changes. | | `KeepVersions` | `int` | `2` | Number of old module versions retained (for rollback). | | `StartupTimeoutSeconds` | `int` | `60` | Max time for a new module version to initialize before automatic rollback. | | `RollingUpdate` | `bool` | `false` | RESERVED — not implemented; nodes reload independently. | | `RemovalDebounceScans` | `int` | `1` | Scan cycles to wait before confirming a DLL removal. | | `Collectible` | `bool` | `false` | Use collectible AssemblyLoadContext: a replaced module version is unloaded once nothing outside it refers to it, and one that stays is logged and counted. With `false` old versions stay in memory until restart. | | `MaxOrphanedContexts` | `int?` | `KeepVersions + 3` | Module contexts left in memory after their modules went before the `hotreload` health check turns Degraded ("restart the node to reclaim memory"). | | `SharedPath` | `string` | `"Libs/shared"` | Directory for shared assemblies loaded into all module contexts. | When `Enabled = false`, the worker loads modules once at startup with no further scanning. ### `Tsak:Watchdog` — Hung Exchange Detection Monitors in-flight route exchanges and alerts when processing takes too long. | Key | Type | Default | Description | |-----|------|---------|-------------| | `Enabled` | `bool` | `true` | Enable watchdog background service. | | `CheckIntervalSeconds` | `int` | `15` | How often to check for stuck exchanges. | | `SuspectedThresholdMinutes` | `double` | `5.0` | Log WARNING if an exchange exceeds this age. | | `HungThresholdMinutes` | `double` | `30.0` | Log ERROR and raise alert if an exchange exceeds this age. | | `AutoRestartHungRoutes` | `bool` | `false` | Automatically stop and restart routes with hung exchanges. | | `AutoRestartTimeoutSeconds` | `int` | `60` | Timeout for the automatic restart operation. | Supports fractional minutes (e.g. `0.5` = 30 seconds). ### `Tsak:Metrics` — Monitoring & Telemetry | Key | Type | Default | Description | |-----|------|---------|-------------| | `CollectionIntervalSeconds` | `int` | `10` | How often metrics are sampled into the circular buffer. | | `HistoryHours` | `int` | `12` | Duration of metric retention. At 10s intervals, 12h = 4,320 data points. | | `ClusterReportIntervalSeconds` | `int` | `60` | How often metrics are reported to the cluster registry (cluster mode only). | | `Prometheus:Enabled` | `bool` | `false` | Enable OpenTelemetry Prometheus exporter. | | `Prometheus:Port` | `int` | `9464` | Prometheus scrape endpoint port. | When Prometheus is enabled, metrics are exported at `http://*:{Port}/metrics` for Grafana or other scrapers. ### `Tsak:Logs` — Live Log Buffer | Key | Type | Default | Description | |-----|------|---------|-------------| | `BufferSize` | `int` | `2000` | Number of log entries retained in the in-memory ring buffer for `/api/logs/tail`. | ### `Tsak:Cluster` — Cluster Coordination (Pro) Requires `Storage:Type = "Redb"` and `Redb:UsePro = true`. Pro is free of charge and needs no key. | Key | Type | Default | Description | |-----|------|---------|-------------| | `Enabled` | `bool` | `false` | Enable cluster mode. If `false`, all cluster services are skipped. | | `ClusterName` | `string` | `"default"` | Logical cluster name. Nodes with different cluster names are isolated (leader, locks, nodes, assignments), even on one database with equal group names or node ids. | | `GroupName` | `string` | `"default"` | Node group within the cluster. Used for module assignment targeting. | | `NodeId` | `string` | hostname | Node identifier, unique within its cluster group. Auto-generated from hostname if empty. | | `ApiEndpoint` | `string` | auto | Public API URL for this node. If empty, built from `Tsak:Api:Host` + `Tsak:Api:Port`. | | `HeartbeatIntervalSeconds` | `int` | `15` | How often the node sends alive signals to the registry. | | `DeadNodeTimeoutSeconds` | `int` | `60` | Seconds without heartbeat before a node is marked dead. | | `LeaderLockTtlSeconds` | `int` | `30` | TTL for the distributed leader lock. | | `Strategy` | `string` | `"round-robin"` | Module assignment strategy: `"round-robin"` or `"least-loaded"`. | When disabled (default), the worker runs as a standalone instance with no inter-node coordination. ### Logging (Serilog) The worker uses [Serilog](https://serilog.net/) with console and file sinks. A custom `MemoryUsageEnricher` adds `{MemoryUsage}` (process working set in KB) to log output. | Key | Description | |-----|-------------| | `Serilog:MinimumLevel:Default` | Global minimum level. | | `Serilog:MinimumLevel:Override:redb.Tsak` | Override for Tsak-specific logs. | | `Serilog:MinimumLevel:Override:redb.Route` | Override for route engine logs. | | `Serilog:MinimumLevel:Override:Quartz` | Override for scheduler logs. | Log files are written to `Logs/log-{Date}.txt` with 7-day retention by default. ### Quartz Scheduler The worker integrates [Quartz.NET](https://www.quartz-scheduler.net/) for cron-triggered routes. | Key | Default | Description | |-----|---------|-------------| | `Quartz:quartz.threadPool.threadCount` | `10` | Scheduler thread pool size. | | `Quartz:quartz.jobStore.type` | `JobStoreTX` | ADO.NET job store for persistence. | | `Quartz:quartz.jobStore.clustered` | `true` | Enable Quartz clustering (requires shared database). | | `Quartz:quartz.scheduler.instanceId` | `NODE` | Scheduler instance ID of every context: `NODE` takes the node id (`Tsak:Cluster:NodeId`, or the host name), `AUTO` lets Quartz draw one per start, any other value is used as written. See the README, "Node identity and Quartz instance". | | `Quartz:quartz.scheduler.instanceName` | `TsakScheduler` | Scheduler name. With AdoJobStore, `TsakScheduler` or an empty name becomes `TsakScheduler-{Tsak:Cluster:ClusterName}`, so each Tsak cluster on a shared database is its own Quartz cluster; any other name is kept. | Quartz tables are auto-created from embedded SQL scripts (`tables_postgres.sql` / `tables_sqlServer.sql`). --- ## Architecture ``` Program.cs └── AddTsak(configuration) ├── ConfigureRedb() Database setup (if Redb provider configured) ├── ConfigureStorage() InMemory or Redb stores ├── TsakModuleRegistry Module catalog ├── TsakContextManager Context lifecycle ├── TsakCoordinator Module ↔ context orchestration ├── SystemContextBuilder Built-in _system context (API, health) ├── ConfigureHotReload() DLL scanning & hot swap ├── ConfigureMonitoring() Metrics, watchdog, Prometheus ├── ConfigureQuartz() Cron scheduler ├── AddTsakCluster() Pro: cluster services (no-op if disabled) └── TsakHostedService Main lifecycle (IHostedService) ``` ### Project Dependencies ``` redb.Tsak.Worker ├── redb.Tsak.Core (module registry, contexts, coordinator, API, monitoring) └── redb.Tsak.Core.Pro (cluster: leader election, node registry, assignments) └── redb.Core.Pro (redb store) ``` ### Module Loading Modules are .NET assemblies placed in `Tsak:Modules:AssemblyPaths` directories. The worker: 1. Scans directories on startup 2. Loads assemblies into isolated `AssemblyLoadContext` 3. Discovers `ITsakModule` implementations 4. Assigns modules to contexts per `Tsak:Contexts` config 5. Starts contexts with `AutoStart = true` If hot-reload is enabled, the worker re-scans directories periodically and hot-swaps changed modules. ### Standalone vs Cluster | Aspect | Standalone | Cluster | |--------|-----------|---------| | `Cluster:Enabled` | `false` (default) | `true` | | Node discovery | N/A — single node | Via redb node registry | | Module assignment | All modules run locally | Distributed by leader node | | Leader election | N/A | Automatic (distributed lock) | | Module hot swap | Local | Each node on its own scan; no cross-node sequencing | | Database required | Only if `Storage:Type = "Redb"` | Always | --- ## Minimal Configuration Examples ### Standalone (no database) ```jsonc { "Tsak": { "Storage": { "Type": "InMemory" }, "Modules": { "AssemblyPaths": ["./Libs"] }, "Contexts": { "default": { "AutoStart": true } }, "Api": { "Enabled": true, "Port": 9090 } } } ``` ### Standalone with Persistent Storage ```jsonc { "ConnectionStrings": { "Postgres": "Host=localhost;Database=redb;Username=postgres;Password=postgres" }, "Tsak": { "Storage": { "Type": "Redb" }, "Redb": { "Provider": "postgres" }, "Modules": { "AssemblyPaths": ["./Libs"] }, "Contexts": { "default": { "AutoStart": true } } } } ``` ### Cluster Mode ```jsonc { "ConnectionStrings": { "Postgres": "Host=db.prod.local;Database=redb;Username=app;Password=secret" }, "Tsak": { "Storage": { "Type": "Redb" }, "Redb": { "Provider": "postgres", "UsePro": true, "PropsSaveStrategy": "ChangeTracking" }, "Cluster": { "Enabled": true, "ClusterName": "production", "GroupName": "workers", "HeartbeatIntervalSeconds": 15, "Strategy": "round-robin" }, "Api": { "Enabled": true, "Port": 9090 }, "Auth": { "Enabled": true, "Keys": [ { "Id": "dashboard", "KeyHash": "", "Name": "web-dashboard", "Roles": "admin" } ] } } } ``` Path: redb-tsak/src/redb.Tsak.Worker/SharedRuntimeBootstrap.cs Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/SharedRuntimeBootstrap.cs ---- using redb.Tsak.Core.Modules; namespace redb.Tsak.Worker; /// /// BCL-only entry hook, invoked as the FIRST statement of the process (see Program.cs), BEFORE /// any redb.* type is touched. Installs the shared-layer resolver and preloads the redb.* /// framework assemblies from Libs/shared so they can be removed from the application bin /// and delivered as swappable patch DLLs. /// /// This class must reference ONLY BCL and (itself BCL-only). It must /// NOT touch any redb.Core/redb.Route type, or those assemblies would load before the resolver /// is installed. lives in redb.Tsak.Core (which stays in bin), and /// merely loading that assembly does not force-load its redb.* dependencies. /// /// internal static class SharedRuntimeBootstrap { /// /// The redb.* assemblies that redb.Tsak.Core references at compile time and therefore touches /// while the host is being built (AddTsak). They MUST be present in the Default ALC before /// that happens. Keep in sync with the redb.* ProjectReferences in redb.Tsak.Core.csproj — /// if a redb.* reference is added there, add it here too. (Diagnostic mirror of /// scripts/shared-manifest.psd1; redb.Tsak.* are NOT listed — they stay in the bin.) /// private static readonly string[] FrameworkAssemblies = [ "redb.Core", "redb.Core.Pro", "redb.Route.Core", "redb.Route.Http", // Extracted from redb.Route.Http in 3.5.1 (SharedHttpServerManager). It reaches Libs/shared // transitively via Http's publish output, but it must ALSO be declared here so the byte-preload // fail-fast and the minor compat-gate cover it — otherwise a mismatched copy is swallowed // silently instead of aborting the start. Keep in sync with scripts/shared-manifest.psd1. "redb.Route.Http.Hosting", // XML route artifacts (the Route-XML wave): compile-ref of redb.Tsak.Core (XmlRouteModule) // and of redb.Route.Http (the contribution). It reaches Libs/shared transitively // either way, but it must ALSO be declared here so the byte-preload fail-fast and the // minor compat-gate cover it — an undeclared assembly is swallowed silently on mismatch // instead of aborting the start. Keep in sync with scripts/shared-manifest.psd1. "redb.Route.Xml", "redb.Route.Quartz", "redb.Route.Sql", "redb.Postgres", "redb.Postgres.Pro", "redb.MSSql", "redb.MSSql.Pro", "redb.SQLite", "redb.SQLite.Pro", ]; /// /// Installs the resolver over Libs/shared and preloads the redb.* framework set. Optional /// verbose logging to stderr when TSAK_SHARED_DEBUG is set (the DI logger is not up yet). /// /// FAIL-FAST: the framework no longer ships in the bin (pruned — see Worker.csproj), so every /// name in MUST resolve from the shared layer. If any is /// missing/corrupt the process refuses to start with a precise message — NOW, deterministically, /// rather than as an obscure MissingMethodException a day later under load. This fail-fast is /// scoped to the framework set only; the lazy transitive tail stays soft (loaded on demand). /// /// public static void InstallEarly() { var verbose = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("TSAK_SHARED_DEBUG")); Action? log = verbose ? (msg => Console.Error.WriteLine(msg)) : null; var sharedPath = Environment.GetEnvironmentVariable("TSAK_SHARED_DIR"); if (string.IsNullOrWhiteSpace(sharedPath)) sharedPath = SharedRuntime.DefaultSharedPath; var missing = SharedRuntime.InstallEarly(sharedPath, FrameworkAssemblies, log); if (missing.Count > 0) { throw new InvalidOperationException( $"Shared runtime layer is incomplete — the redb.* framework could not be loaded from " + $"'{sharedPath}'. Startup aborted (fail-fast). Missing/unloadable:{Environment.NewLine} " + string.Join(Environment.NewLine + " ", missing) + Environment.NewLine + "Rebuild the shared layer: scripts/build-shared.ps1 -IncludeFramework " + "(or set TSAK_SHARED_DIR to a complete shared directory)."); } AssertFrameworkCompatible(log); } /// /// COMPAT-GATE: the framework now comes from an external shared layer that could be swapped, so /// we verify on startup that it matches THIS Tsak build's minor. Patch differences are allowed /// (that is the whole point — leaf/provider patches ship independently); a minor mismatch, or a /// mix of minors inside the shared layer, aborts startup with a precise message instead of a /// cryptic MissingMethodException deep in a request later. Expected minor is derived from /// redb.Tsak.Core's own version (the ecosystem number), so there is nothing to hand-maintain. /// private static void AssertFrameworkCompatible(Action? log) { var expected = typeof(SharedRuntime).Assembly.GetName().Version; // = redb.Tsak.Core version if (expected is null) return; var problems = new List(); // Representative contract libs must match Tsak's major.minor exactly. foreach (var name in new[] { "redb.Core", "redb.Route.Core" }) { var v = SharedRuntime.GetLoadedVersion(name); if (v is null) { problems.Add($"{name}: not loaded"); continue; } if (v.Major != expected.Major || v.Minor != expected.Minor) problems.Add($"{name} is {v.Major}.{v.Minor}, expected {expected.Major}.{expected.Minor}"); } // The whole redb.* framework in the shared layer must share ONE minor (catch "forgot to // update one provider" — a patch swap that pulled in a different minor). var minors = FrameworkAssemblies .Select(SharedRuntime.GetLoadedVersion) .Where(v => v is not null) .Select(v => $"{v!.Major}.{v.Minor}") .Distinct() .ToList(); if (minors.Count > 1) problems.Add($"shared layer mixes redb minors: {string.Join(", ", minors)}"); if (problems.Count > 0) { throw new InvalidOperationException( $"redb ecosystem version mismatch — this is Tsak {expected.Major}.{expected.Minor} but the " + $"shared layer is incompatible. Startup aborted (compat-gate):{Environment.NewLine} " + string.Join(Environment.NewLine + " ", problems) + Environment.NewLine + "The shared layer must match Tsak's minor (patches may differ). Rebuild it from the same " + "ecosystem release."); } log?.Invoke($"[shared] compat-gate ok: framework minor {expected.Major}.{expected.Minor}"); } } Path: redb-tsak/src/redb.Tsak.Worker/Utils/MemoryUsageEnricher.cs Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/Utils/MemoryUsageEnricher.cs ---- using Serilog.Core; using Serilog.Events; namespace redb.Tsak.Worker.Utils; public class MemoryUsageEnricher : ILogEventEnricher { public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) { var memoryUsage = GC.GetTotalMemory(false) / 1024; // KB var property = propertyFactory.CreateProperty("MemoryUsage", memoryUsage); logEvent.AddPropertyIfAbsent(property); } } Path: redb-tsak/src/redb.Tsak.Worker/Utils/StartupBanner.cs Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/Utils/StartupBanner.cs ---- using System.Reflection; using System.Text; namespace redb.Tsak.Worker.Utils; /// /// ASCII startup banner for redb.Tsak container. /// public static class StartupBanner { public static void Print(Assembly? assembly = null) { assembly ??= Assembly.GetExecutingAssembly(); try { var version = assembly.GetCustomAttribute() ?.InformationalVersion?.Split('+')[0] ?? assembly.GetName().Version?.ToString() ?? "0.0.0"; Console.Write(Build(version)); } catch { Console.WriteLine($"=== REDB TSAK v{assembly.GetName().Version?.ToString() ?? "?"} ==="); } } private static string Build(string version) { var sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(" ██████╗ ███████╗██████╗ ██████╗ ████████╗███████╗ █████╗ ██╗ ██╗"); sb.AppendLine(" ██╔══██╗██╔════╝██╔══██╗██╔══██╗ ╚══██╔══╝██╔════╝██╔══██╗██║ ██╔╝"); sb.AppendLine(" ██████╔╝█████╗ ██║ ██║██████╔╝ ██║ ███████╗███████║█████╔╝ "); sb.AppendLine(" ██╔══██╗██╔══╝ ██║ ██║██╔══██╗ ██║ ╚════██║██╔══██║██╔═██╗ "); sb.AppendLine(" ██║ ██║███████╗██████╔╝██████╔╝ ██║ ███████║██║ ██║██║ ██╗"); sb.AppendLine(" ╚═╝ ╚═╝╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝"); sb.AppendLine(); sb.AppendLine(" ROUTE CONTAINER SYSTEM"); sb.AppendLine(); sb.AppendLine(FmtLine("Version:", version)); sb.AppendLine(FmtLine("Runtime:", Environment.Version.ToString())); sb.AppendLine(FmtLine("OS:", Environment.OSVersion.VersionString)); sb.AppendLine(FmtLine("Started:", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); sb.AppendLine(); sb.AppendLine(" by relikt"); sb.AppendLine(); return sb.ToString(); } private static string FmtLine(string label, string value) => $" {label,-12} {value}"; } Path: redb-tsak/src/redb.Tsak.Worker/appsettings.json Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/appsettings.json ---- { "ConnectionStrings": { "Postgres": "Host=localhost;Port=5432;Username=postgres;Password=;Database=redb;Pooling=true;Include Error Detail=true", "MSSql": "Server=msdb;Database=redb;User Id=sa;Password=;TrustServerCertificate=true;Command Timeout=600;", "//Sqlite": "A relative path resolves against the working directory; the cluster dashboard must use the same database file.", "Sqlite": "Data Source=../../redb.db" }, "Tsak": { "Storage": { "Type": "Redb" }, "Redb": { "//Provider": "postgres | mssql | sqlite — Sqlite uses ConnectionStrings:Sqlite (Data Source=…db)", "Provider": "sqlite", "UsePro": true, "PropsSaveStrategy": "ChangeTracking", "//Cache": "redb cache tuning. Values below are redb's own defaults — an absent section changes nothing.", "Cache": { "EnableProps": false, "PropsMaxSize": 10000, "PropsTtlMinutes": 60, "//SkipHashValidationOnCacheCheck": "true = trust cache without re-checking the object hash in DB (faster, single-writer only). MUST be false in a cluster — can serve stale data.", "SkipHashValidationOnCacheCheck": false, "EnableList": true, "ListTtlMinutes": 5, "EnableMetadata": true, "MetadataTtlMinutes": 30, "AutoRecomputeHash": true, "//CacheDomain": "isolate scheme caches between databases; empty = derived from the connection string hash", "CacheDomain": "" } }, "Modules": { "//AssemblyPaths": "Relative entries resolve against the working directory.", "AssemblyPaths": [ "modules" ] }, "Contexts": { "default": { "AutoStart": true } }, "Cluster": { // STANDALONE // "Enabled": false, // CLUSTER (active) "Enabled": true, "ClusterName": "default", "GroupName": "default", "NodeId": "", // ApiEndpoint MUST be the address OTHER machines reach this node at (dashboard included). // Empty = auto-detect from Tsak:Api (hostname-based). A literal localhost here made every // node register the same loopback address and all dashboard actions hit the wrong worker // (review 2026-09-02, К6). In k8s set it from the pod IP (see deploy/k8s/deployment.yaml). "ApiEndpoint": "", "HeartbeatIntervalSeconds": 15, "DeadNodeTimeoutSeconds": 60, "LeaderLockTtlSeconds": 30, "Strategy": "round-robin" }, "HotReload": { "Enabled": true, "ScanIntervalSeconds": 10, "KeepVersions": 2, "StartupTimeoutSeconds": 60, "RollingUpdate": false, "Collectible": false }, "Metrics": { "CollectionIntervalSeconds": 10, "HistoryHours": 12, "ClusterReportIntervalSeconds": 60, "Prometheus": { // Metrics are scraped from the Tsak facade: http://:/metrics // (auth-exempt). The OTel listener binds loopback :Port internally — no admin, no URL // ACL, no extra externally-exposed port on any OS. Just set Enabled (+ optional Port). "Enabled": true, "Port": 9464, "AdditionalMeters": [], "AdditionalSources": [] } }, "Tracing": { "ServiceName": "redb-tsak-worker", "Otlp": { // OpenTelemetry trace export. OFF by default. When Enabled=true, route/step spans // (and any AdditionalSources above) ship to the OTLP Endpoint — point it at a // collector or directly at Jaeger (native OTLP: gRPC :4317, http/protobuf :4318). "Enabled": true, "Endpoint": "http://localhost:4317", "Protocol": "grpc" } }, "Api": { "Enabled": true, "Host": "0.0.0.0", "Port": 9090, "Echo": { // Auth-exempt route 'system-echo' on the main API port that reflects the request back // as JSON (liveness/debug probe). Its concrete path out-ranks the catch-all dispatcher // (specificity ordering), so no separate port is needed. Ships with AutoStart=false — // start it from the Routes API / dashboard when you need it. "Path": "/api/echo" } }, "Logs": { "BufferSize": 2000 }, "Watchdog": { "Enabled": true, "CheckIntervalSeconds": 10, "SuspectedThresholdMinutes": 0.5, "HungThresholdMinutes": 1.5, "AutoRestartHungRoutes": false }, "Auth": { "Enabled": true, "Secret": "", "Keys": [ { "Id": "svc-web-dashboard", "KeyHash": "AD595EC6C321E437453D29496F9024759765AC9B7D720DB853DF82960E958F72", "Name": "web-dashboard", "Roles": "admin", "UserId": null } ] } }, "Quartz": { "quartz.threadPool.type": "Quartz.Simpl.SimpleThreadPool, Quartz", "quartz.threadPool.threadCount": "10", "quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz", // clustered=true because the AdoJobStore points at the SAME redb database every node uses: // two non-clustered schedulers with one name on one qrtz_* set double-fire triggers and // corrupt each other's state (review 2026-09-02, В11). Single-node deployments are fine // with clustered=true too (slightly more locking). "quartz.jobStore.clustered": "true", "quartz.jobStore.acquireTriggersWithinLock": "true", "quartz.scheduler.instanceId": "NODE", "quartz.scheduler.instanceName": "TsakScheduler" }, "Serilog": { "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "System": "Information", "System.Net.Http": "Warning", "Quartz": "Information", "redb.Tsak": "Information", "redb.Route": "Information", "redb.Identity": "Information", "OpenIddict": "Warning" } }, "WriteTo": [ { "Name": "Console", "Args": { "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [Mem: {MemoryUsage:N0} KB] {Message:lj} {NewLine}{Exception}" } }, { "Name": "File", "Args": { "path": "Logs/log-.txt", "rollingInterval": "Day", "retainedFileCountLimit": 7, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [Mem: {MemoryUsage:N0} KB] {Message:lj} {NewLine}{Exception}" } } ], "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId", "WithEnvironmentName", "WithProcessId", "WithProcessName", "WithThreadName" ] } } Path: redb-tsak/src/redb.Tsak.Worker/redb.Tsak.Worker.csproj Snapshot: redb-tsak, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-tsak Page: https://redbase.app/src/dev-2026-12-06/redb-tsak/src/redb.Tsak.Worker/redb.Tsak.Worker.csproj ---- net10.0 Linux <_RedbToPrune Include="$(OutDir)redb.*.dll;$(OutDir)redb.*.pdb" Exclude="$(OutDir)redb.Tsak.*;$(OutDir)redb.Licensing.*" /> <_RedbToPrunePub Include="$(PublishDir)redb.*.dll;$(PublishDir)redb.*.pdb" Exclude="$(PublishDir)redb.Tsak.*;$(PublishDir)redb.Licensing.*" />