Class FixedTimeoutHandler

java.lang.Object
org.tinyradius.io.client.timeout.FixedTimeoutHandler
All Implemented Interfaces:
TimeoutHandler

public class FixedTimeoutHandler extends Object implements TimeoutHandler
TimeoutHandler that waits a fixed period for every timeout, up to a predefined max attempt count.
  • Constructor Details

    • FixedTimeoutHandler

      public FixedTimeoutHandler(io.netty.util.Timer timer)
    • FixedTimeoutHandler

      public FixedTimeoutHandler(io.netty.util.Timer timer, int maxAttempts, int timeoutMs)
      Parameters:
      timer - netty timer for timing out requests
      maxAttempts - max number of attempts to try before returning failure
      timeoutMs - time to wait before timeout or next retry, in milliseconds
  • Method Details

    • onTimeout

      public void onTimeout(Runnable retry, int totalAttempts, io.netty.util.concurrent.Promise<RadiusResponse> promise)
      Description copied from interface: TimeoutHandler
      Schedule a retry in the future. Invoked immediately after a request is sent to schedule next retry.

      When retry is due to run, should also check if promise isDone() before running.

      Implemented here instead of RadiusClient so custom scheduling / retry backoff can be used depending on implementation, and actual retry can be deferred. Scheduling and logic should be implemented here, while RadiusClient only deals with IO.

      Specified by:
      onTimeout in interface TimeoutHandler
      Parameters:
      retry - runnable to invoke to retry
      totalAttempts - current attempt count
      promise - request promise that resolves when a response is received