Issue: Graceful Shutdown via InFlightTaskTracker
Summary
Enable graceful shutdown (e.g. Pod drain in Kubernetes) by tracking in-flight context tasks outside the core, subscribing to lifecycle events, and waiting for drain before exit.
Constraint / Decision
Core does not track active tasks (No Global Lock, no global registry per 9.2/10.4). Counting live in an external component (InFlightTaskTracker) in the hosting/adapter layer.
Flow
- Hosting (e.g.
IHostedService) signals intention to stop.
InFlightTaskTracker counts tasks by subscribing to ContextLifecycleEvent (Started / Completed).
- On stop signal, the host waits until the counter hits zero.
- Core
ContextManager keeps working undisturbed during drain.
Scope
Design Expectations
- Tracking lives outside Core (adapter/hosting).
- Uses lifecycle events already emitted (K9/K10) — no core changes.
- Non-blocking to
ContextManager.
Non-Goals
- No policy/queue persistence.
- No APM sink.
Issue: Graceful Shutdown via
InFlightTaskTrackerSummary
Enable graceful shutdown (e.g. Pod drain in Kubernetes) by tracking in-flight context tasks outside the core, subscribing to lifecycle events, and waiting for drain before exit.
Constraint / Decision
Core does not track active tasks (No Global Lock, no global registry per 9.2/10.4). Counting live in an external component (
InFlightTaskTracker) in the hosting/adapter layer.Flow
IHostedService) signals intention to stop.InFlightTaskTrackercounts tasks by subscribing toContextLifecycleEvent(Started/Completed).ContextManagerkeeps working undisturbed during drain.Scope
InFlightTaskTracker(hosting side) counting inflight via lifecycle events.IHostedServicedrain +CancellationToken.ContextManager; no blocking.Design Expectations
ContextManager.Non-Goals