Class TransportHealth
java.lang.Object
express.mvp.myra.transport.TransportHealth
Health status and metrics for a transport instance.
This immutable class provides a snapshot of transport health including connection state, throughput metrics, and error information.
Health Metrics
- healthy: Overall health status (false if recent errors)
- activeConnections: Number of currently active connections
- pendingOperations: Operations submitted but not completed
- totalBytesSent/Received: Cumulative throughput counters
Usage Example
TransportHealth health = transport.getHealth();
if (!health.isHealthy()) {
System.err.println("Transport unhealthy: " + health.getErrorMessage());
System.err.println("Last error at: " + health.getLastError());
}
System.out.println("Active connections: " + health.getActiveConnections());
System.out.println("Throughput: " + health.getTotalBytesSent() + " bytes sent");
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructingTransportHealthinstances. -
Method Summary
Modifier and TypeMethodDescriptionstatic TransportHealth.Builderbuilder()Creates a new builder for constructing health snapshots.intReturns the number of active connections.Returns the message describing the most recent error.Returns the timestamp of the most recent error.intReturns the number of I/O operations pending completion.longReturns the total bytes received since transport creation.longReturns the total bytes sent since transport creation.booleanReturns whether the transport is healthy.
-
Method Details
-
builder
Creates a new builder for constructing health snapshots.- Returns:
- a new builder with default values
-
isHealthy
public boolean isHealthy()Returns whether the transport is healthy.A transport is considered unhealthy if errors have occurred since the last health check.
- Returns:
trueif healthy,falseif errors have occurred
-
getActiveConnections
public int getActiveConnections()Returns the number of active connections.- Returns:
- the active connection count
-
getPendingOperations
public int getPendingOperations()Returns the number of I/O operations pending completion.High values may indicate backpressure or slow downstream processing.
- Returns:
- the pending operation count
-
getTotalBytesSent
public long getTotalBytesSent()Returns the total bytes sent since transport creation.- Returns:
- cumulative bytes sent
-
getTotalBytesReceived
public long getTotalBytesReceived()Returns the total bytes received since transport creation.- Returns:
- cumulative bytes received
-
getLastError
Returns the timestamp of the most recent error.- Returns:
- the error timestamp, or
nullif no errors
-
getErrorMessage
Returns the message describing the most recent error.- Returns:
- the error message, or
nullif no errors
-