Package com.guinetik.rr.interceptor
Interface InterceptorChain
-
public interface InterceptorChainRepresents the interceptor chain during request execution.This interface is passed to
RequestInterceptor.onError(com.guinetik.rr.http.RocketRestException, com.guinetik.rr.request.RequestSpec<Req, Res>, com.guinetik.rr.interceptor.InterceptorChain)to allow interceptors to retry failed requests or query chain state.Retry Example
public <Req, Res> Res onError(RocketRestException e, RequestSpec<Req, Res> request, InterceptorChain chain) throws RocketRestException { if (isRetryable(e) && chain.getRetryCount() < 3) { return chain.retry(request); } throw e; }- Since:
- 1.1.0
- Author:
- guinetik <guinetik@gmail.com>
- See Also:
RequestInterceptor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intgetMaxRetries()Gets the maximum retry count configured for this chain.intgetRetryCount()Gets the current retry count for this execution.<Req,Res>
Resretry(RequestSpec<Req,Res> request)Retries the request from the beginning of the chain.
-
-
-
Method Detail
-
retry
<Req,Res> Res retry(RequestSpec<Req,Res> request) throws RocketRestException
Retries the request from the beginning of the chain.This increments the retry count and re-executes the full interceptor chain, including all beforeRequest/afterResponse hooks.
- Type Parameters:
Req- The request body typeRes- The response type- Parameters:
request- The request to retry (can be modified from original)- Returns:
- The response from the retried request
- Throws:
RocketRestException- If the retry also fails
-
getRetryCount
int getRetryCount()
Gets the current retry count for this execution.Starts at 0 for the initial request, increments with each retry. Use this to implement retry limits.
- Returns:
- The number of retries attempted so far
-
getMaxRetries
int getMaxRetries()
Gets the maximum retry count configured for this chain.Returns 0 if no retry limit is configured.
- Returns:
- The maximum retry count, or 0 if unlimited
-
-