Package 

Interface StreamHealthMonitor

  • All Implemented Interfaces:
    io.getstream.android.core.api.observers.StreamStartableComponent

    
    public interface StreamHealthMonitor
     implements StreamStartableComponent
                        

    Monitors the health and liveness of a system or connection by tracking periodic heartbeats and thresholds for missed acknowledgments.

    Typical usage:

    • Register a callback to be invoked on every heartbeat tick (e.g., for diagnostics).

    • Register a callback to be invoked if no acknowledgment occurs within the allowed threshold.

    • Call acknowledgeHeartbeat when receiving a valid "I'm alive" signal.

    • Start and stop the monitor as needed.

    • Method Summary

      Modifier and Type Method Description
      abstract Unit onHeartbeat(SuspendFunction0<Unit> callback) Registers a callback that is invoked at every heartbeat interval.
      abstract Unit onUnhealthy(SuspendFunction0<Unit> callback) Registers a callback that is invoked when the liveness threshold is exceeded.
      abstract Unit acknowledgeHeartbeat() Acknowledges a heartbeat signal.
      • Methods inherited from class io.getstream.android.core.api.socket.monitor.StreamHealthMonitor

        start, stop
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • onHeartbeat

         abstract Unit onHeartbeat(SuspendFunction0<Unit> callback)

        Registers a callback that is invoked at every heartbeat interval.

        This can be used for periodic checks, metrics collection, or emitting a signal to verify that the system is responsive.

        Parameters:
        callback - A function to be called on each heartbeat tick.
      • onUnhealthy

         abstract Unit onUnhealthy(SuspendFunction0<Unit> callback)

        Registers a callback that is invoked when the liveness threshold is exceeded.

        This typically means no acknowledgment was received within the expected time frame, and the monitored system should be considered unhealthy, stalled, or disconnected.

        Parameters:
        callback - A function to be called when the liveness timeout occurs.
      • acknowledgeHeartbeat

         abstract Unit acknowledgeHeartbeat()

        Acknowledges a heartbeat signal.

        This should be called whenever the monitored system successfully responds, indicating that it is alive and healthy. Resets the liveness timer.