Class EndpointBase<TOptions>
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
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; }
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; }
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; }
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; }
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(Exception)
Record a processing error with exception details. Thread-safe.
public void RecordError(Exception exception)
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(string)
Record a processing warning with message. Thread-safe.
public void RecordWarning(string message)
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)
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.