Class EndpointBase<TOptions>

Namespace: redb.Route.Core
Assembly: redb.Route.dll

Base class for endpoints with built-in lightweight statistics tracking.
All counters use for thread safety with zero lock contention.
Consumers call //
to update counters; external code reads via .

public abstract class EndpointBase<TOptions> : IEndpoint, IEndpointStatistics where TOptions : EndpointOptions

Inheritance

Object→EndpointBase<TOptions>

Implements

Properties

AverageProcessingTime

Average processing time over the last 100 messages.

public TimeSpan AverageProcessingTime { get; }

BytesIn

Bytes that entered the endpoint (estimated from message bodies): what a consumer received,

public long BytesIn { get; }

BytesOut

Bytes that left the endpoint: what a producer sent, and what a consumer wrote back as a

public long BytesOut { get; }

Cancelled

Exchanges abandoned by a cooperative cancellation: the caller's token was cancelled while

public long Cancelled { get; }

Component

The component that created this endpoint.

public IComponent Component { get; }

Errors

Number of errors during processing.

public long Errors { get; }

HealthReason

Human-readable reason for the current health status.

public string HealthReason { get; }

HealthStatus

Health status computed from error rate and activity.

public EndpointHealthStatus HealthStatus { get; }

LastActivity

Timestamp of the last message activity (in or out), or null if no activity yet.

public DateTime? LastActivity { get; }

LastErrorMessage

Message text of the last error, or empty string.

public string LastErrorMessage { get; }

LastErrorTime

Timestamp of the last error, or null if no errors.

public DateTime? LastErrorTime { get; }

LastRefusalMessage

Why the last request was refused, or empty string.

public string LastRefusalMessage { get; }

LastRefusalTime

Timestamp of the last refusal, or null if none.

public DateTime? LastRefusalTime { get; }

LastWarningMessage

Message text of the last warning, or empty string.

public string LastWarningMessage { get; }

LastWarningTime

Timestamp of the last warning, or null if no warnings.

public DateTime? LastWarningTime { get; }

MessagesIn

Number of messages received (consumed) by this endpoint.

public long MessagesIn { get; }

MessagesOut

Number of messages sent (produced) by this endpoint.

public long MessagesOut { get; }

Options

Typed options bound from URI parameters.

protected TOptions Options { get; }

Reconnects

Connections or links of this endpoint that were lost while a route ran and came back, as its connection supervisors

public long Reconnects { get; }

Refused

Requests the transport refused as the caller's fault and answered with the protocol's own error: malformed or

public long Refused { get; }

Rejected

Requests shed by an admission limit (e.g. maxConcurrentRequests) BEFORE a pipeline

public long Rejected { get; }

ScopeFactory

Scope factory for per-exchange DI scope creation. Set by RouteContext.

public IServiceScopeFactory? ScopeFactory { get; set; }

StartTime

Timestamp when the endpoint started tracking statistics.

public DateTime StartTime { get; }

ThroughputPerSecond

Messages per second over a 60-second sliding window.

public double ThroughputPerSecond { get; }

TransportCondition

A state the endpoint knows from its transport and the counters cannot show, such as a broker that blocks the

protected virtual (EndpointHealthStatus Status, string Reason)? TransportCondition { get; }

Uptime

Duration the endpoint has been tracking statistics.

public TimeSpan Uptime { get; }

Uri

Parsed URI identifying this endpoint.

public EndpointUri Uri { get; }

Warnings

Number of warnings during processing.

public long Warnings { get; }

Methods

CreateConsumer(IProcessor)

Creates a consumer for receiving messages from this endpoint.

public abstract IConsumer CreateConsumer(IProcessor processor)

CreateProducer()

Creates a producer for sending messages to this endpoint.

public abstract IProducer CreateProducer()

RecordBytesIn(long)

Record incoming bytes (message body size). Thread-safe.

public void RecordBytesIn(long bytes)

RecordBytesOut(long)

Record outgoing bytes (message body size). Thread-safe.

public void RecordBytesOut(long bytes)

RecordCancelled()

Record an exchange abandoned by a cooperative cancellation. Thread-safe.

public void RecordCancelled()

RecordError()

Record a processing error. Thread-safe.

public void RecordError()

RecordError(Exception)

Record a processing error with exception details. Thread-safe.

public void RecordError(Exception exception)

RecordMessageIn()

Record an incoming message (consumed). Thread-safe.

public void RecordMessageIn()

RecordMessageOut()

Record an outgoing message (produced). Thread-safe.

public void RecordMessageOut()

RecordProcessingTime(TimeSpan)

Record processing time of a single message. Thread-safe.

public void RecordProcessingTime(TimeSpan duration)

RecordRefused(string)

Record a request refused as the caller's fault, with the reason (see ). Thread-safe.

public void RecordRefused(string reason)

RecordRejected()

Record a request shed by an admission limit before the pipeline ran. Thread-safe.

public void RecordRejected()

RecordWarning()

Record a processing warning. Thread-safe.

public void RecordWarning()

RecordWarning(string)

Record a processing warning with message. Thread-safe.

public void RecordWarning(string message)

ResetStatistics()

Resets all counters to zero.

public void ResetStatistics()

Start(CancellationToken)

Starts the endpoint lifecycle.

public virtual Task Start(CancellationToken ct = default)

Stop(CancellationToken)

Stops the endpoint lifecycle.

public virtual Task Stop(CancellationToken ct = default)

Supervise(ConnectionSupervisor)

Registers a supervisor: its becomes part of this endpoint's health (the

public void Supervise(ConnectionSupervisor supervisor)

Supervise(string, ILogger?)

Creates a for one connection or link of this endpoint, with the context's

public ConnectionSupervisor Supervise(string name, ILogger? logger)

ToString()

Returns a string that represents the current object.

public override string ToString()

Unsupervise(ConnectionSupervisor)

Removes a supervisor registered with ; its condition no longer counts.

public void Unsupervise(ConnectionSupervisor supervisor)

Constructors

EndpointBase(EndpointUri, IComponent, TOptions)

Creates an endpoint with parsed URI, owning component, and bound options.