Path: redb-tsak/src/redb.Tsak.Core/Contracts/ITsakContextManager.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.Core/Contracts/ITsakContextManager.cs
----
using redb.Route.Abstractions;
using redb.Tsak.Contracts;
namespace redb.Tsak.Core.Contracts;
///
/// Manages lifecycle of route contexts: create, start, stop, remove.
/// Supports named (config-driven) and anonymous (auto-created) contexts.
/// Equivalent of lt.tsak IRouteContextManager.
///
public interface ITsakContextManager
{
///
/// Creates a named context with the given configuration.
///
/// Unique context name.
/// DI service provider for the context.
/// Context-specific configuration values.
/// Created route context.
IRouteContext CreateContext(string contextName, IServiceProvider serviceProvider, IDictionary configuration);
/// Gets a context by name.
IRouteContext? GetContext(string contextName);
/// Returns all contexts as (name, context) pairs.
IReadOnlyList<(string Name, IRouteContext Context)> GetAllContexts();
///
/// Named redb instances as the manager actually registered them, context by context. The context registry
/// itself cannot be enumerated, and an instance whose creation failed is not listed — the storage page
/// offers to query what it lists.
///
IReadOnlyList GetNamedRedbInstances();
/// Starts a context. When ignoreAutoStart is true, skips the autoStart check (for manual API/CLI calls).
Task StartContextAsync(string contextName, bool ignoreAutoStart = false);
/// Stops a context with graceful drain. Returns drain diagnostics.
/// Context name.
/// If true, marks context to not auto-start on next boot.
/// Cancellation token for graceful shutdown timeout.
Task StopContextAsync(string contextName, bool setAutoStartFalse = true, CancellationToken ct = default);
/// Restarts a context (drain-aware stop + start). Returns drain diagnostics.
Task RestartContextAsync(string contextName, CancellationToken ct = default);
/// Removes a context (stop + dispose + unregister).
/// Context name.
/// When true, preserves autoStart state in store (for hot-reload). When false, cleans up everything.
Task RemoveContextAsync(string contextName, bool preserveState = false);
/// Returns whether the context should auto-start based on config.
bool ShouldAutoStart(string contextName);
/// Async version of — avoids sync-over-async for Redb-backed store.
Task ShouldAutoStartAsync(string contextName);
}