Class TransportHealth

java.lang.Object
express.mvp.myra.transport.TransportHealth

public final class TransportHealth extends Object
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:
  • Method Details

    • builder

      public static TransportHealth.Builder 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:
      true if healthy, false if 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

      public Instant getLastError()
      Returns the timestamp of the most recent error.
      Returns:
      the error timestamp, or null if no errors
    • getErrorMessage

      public String getErrorMessage()
      Returns the message describing the most recent error.
      Returns:
      the error message, or null if no errors