Path: redb-route/redb.Route/Core/ConnectionEvent.cs
Snapshot: redb-route, 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-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Core/ConnectionEvent.cs
----
namespace redb.Route.Core;
/// What changed in a supervised connection.
public enum ConnectionEventKind
{
/// The connection was lost.
Lost,
/// An attempt to restore it failed.
AttemptFailed,
/// It was restored.
Restored,
}
///
/// One change of a supervised connection: lost, a reconnect attempt failed, restored. A
/// reports it; the route context hands it to every
/// and, as the events ConnectionLost,
/// ReconnectFailed and ConnectionRestored, to the routes that read controlbus:notify. Listeners get
/// it from a queue, after the change: what they do cannot hold up or break the reconnect.
///
/// What changed.
/// The supervisor's name: which connection or link.
/// The state after the change.
/// The exception of the loss or of the failed attempt; null on .
/// Failed attempts since the loss; 0 on .
/// Time until the next attempt; null on .
/// How long the connection has been lost; on , how long it was.
/// Losses this supervisor recovered from, this one included when restored.
/// When the change happened.
public sealed record ConnectionEvent(
ConnectionEventKind Kind,
string Connection,
ConnectionState State,
Exception? Error,
int Attempt,
TimeSpan? NextDelay,
TimeSpan Outage,
long Reconnects,
DateTimeOffset Time)
{
/// The endpoint the connection belongs to, in its short form with secrets masked.
public string Endpoint { get; init; } = string.Empty;
/// The route that reads from the endpoint; null for a producer, or when several routes share it.
public string? RouteId { get; init; }
/// The message of with secrets masked, as the log and the health reason show it.
public string? ErrorMessage { get; init; }
}
///
/// Receives the changes of a . is called on the thread that reported
/// the change, under the supervisor's lock, so the changes of one connection arrive in their order: it must return at
/// once, never throw and never call back into the supervisor.
///
internal interface IConnectionEventSink
{
/// Takes one change; returns at once.
void Post(ConnectionEvent change);
}