Package org.tinyradius.io.client.timeout
Class FixedTimeoutHandler
java.lang.Object
org.tinyradius.io.client.timeout.FixedTimeoutHandler
- All Implemented Interfaces:
TimeoutHandler
TimeoutHandler that waits a fixed period for every timeout,
up to a predefined max attempt count.
-
Constructor Summary
ConstructorsConstructorDescriptionFixedTimeoutHandler
(io.netty.util.Timer timer) FixedTimeoutHandler
(io.netty.util.Timer timer, int maxAttempts, int timeoutMs) -
Method Summary
Modifier and TypeMethodDescriptionvoid
onTimeout
(Runnable retry, int totalAttempts, io.netty.util.concurrent.Promise<RadiusResponse> promise) Schedule a retry in the future.
-
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 requestsmaxAttempts
- max number of attempts to try before returning failuretimeoutMs
- 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 interfaceTimeoutHandler
- Parameters:
retry
- runnable to invoke to retrytotalAttempts
- current attempt countpromise
- request promise that resolves when a response is received
-