Class Watchdog

java.lang.Object
com.google.api.gax.rpc.Watchdog
All Implemented Interfaces:
BackgroundResource, AutoCloseable, Runnable

public final class Watchdog extends Object implements Runnable, BackgroundResource
Prevents the streams from hanging indefinitely. This middleware garbage collects idle streams in case the user forgot to close a ServerStream or if a connection is reset and GRPC does not get notified.

For every checkInterval, this class checks two thresholds:

  • waitingTimeout: the amount of time to wait for a response (after the caller signaled demand) before forcefully closing the stream. Duration.ZERO disables the timeout.
  • idleTimeout: the amount of time to wait before assuming that the caller forgot to close the stream and forcefully closing the stream. This is measured from the last time the caller had no outstanding demand. Duration.ZERO disables the timeout.