eve.aio.shutdown

Graceful shutdown coordination for Layer 2 components.

This module provides a mechanism to coordinate the shutdown of multiple listeners and connections, ensuring that in-flight requests are finished before the process exits.

Types 3

enumShutdownPhase : ubyte

Phases of the graceful shutdown process.

RUNNINGServer is running normally.
DRAININGListeners are stopped, connections are draining.
TERMINATINGTimeout reached, remaining connections are being forced closed.
STOPPEDAll tracked resources are closed.

Interface for components that can be tracked by the ShutdownCoordinator.

This is an internal interface used by Layer 2 components to integrate with the graceful shutdown process.

Methods
void initiateShutdown(CancelToken token) @safe nothrow;Initiate shutdown for this component.
void performDrain() @safe nothrow;Transition to draining state (stop accepting new requests).
void forceAbort() @safe nothrow;Forcefully close the component.
bool isClosed() @property const @safe nothrow @nogcCheck if the component is fully closed and can be untracked.
structShutdownCoordinator(uint MaxTracked = 1024)

Coordinator for graceful server shutdown.

Tracks active listeners and connections, and manages the multi-phase shutdown protocol to ensure clean termination.

Parameters

MaxTrackedMaximum number of components that can be tracked.
Fields
private EventLoop * _loop
private IShutdownTrackable[MaxTracked] _tracked
private uint _count
private CancelSource _shutdownSource
private ShutdownPhase _phase
private Token _drainTimer
Methods
ShutdownCoordinator create(ref EventLoop loop) @trusted nothrowCreate a coordinator associated with an event loop.
bool track(IShutdownTrackable component) @safe nothrowTrack a component for graceful shutdown.
void shutdown(Duration timeout) @trusted nothrowStart the graceful shutdown process.
CancelToken shutdownToken() @property @safe nothrow @nogcGet the global shutdown cancellation token.
ShutdownPhase phase() @property const @safe nothrow @nogcGet the current shutdown phase.
void checkProgress() @trusted nothrowCheck progress and transition phases if necessary.
void onDrainTimeout() @trusted nothrow
void finish() @safe nothrow