Skip to content

Commit

Permalink
Document exec chain behaviour when automatic retries are enabled. (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
cachescrubber authored Aug 31, 2023
1 parent f00e18d commit 509ba67
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

import java.io.IOException;

import org.apache.hc.client5.http.impl.ChainElement;
import org.apache.hc.client5.http.impl.async.AsyncHttpRequestRetryExec;
import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpException;
Expand All @@ -39,8 +42,20 @@
* chain. Handlers can either be a decorator around another element that implements
* a cross cutting aspect or a self-contained executor capable of producing a response
* for the given request.
*
* <p>
* For information regarding the handler chain behaviour in case of a request re-execution,
* please refer to the {@link AsyncHttpRequestRetryExec} javadoc.
* </p>
* <p>
* Well known request execution handlers could be referred to by name using one of the
* {@link ChainElement} enum values.
* </p>
* @since 5.0
* @see ChainElement
* @see HttpAsyncClientBuilder#addExecInterceptorFirst(String, AsyncExecChainHandler)
* @see HttpAsyncClientBuilder#addExecInterceptorBefore(String, String, AsyncExecChainHandler)
* @see HttpAsyncClientBuilder#addExecInterceptorAfter(String, String, AsyncExecChainHandler)
* @see HttpAsyncClientBuilder#addExecInterceptorLast(String, AsyncExecChainHandler)
*/
@Contract(threading = ThreadingBehavior.STATELESS)
public interface AsyncExecChainHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

import java.io.IOException;

import org.apache.hc.client5.http.impl.ChainElement;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.ClassicHttpRequest;
Expand All @@ -46,8 +49,21 @@
* by calling {@link ClassicHttpResponse#close()} methods in case of an I/O, protocol or
* runtime exception, or in case the response is not propagated to the caller.
* </p>
* <p>
* For information regarding the handler chain behaviour in case of a request re-execution,
* please refer to the {@link HttpRequestRetryExec} javadoc.
* </p>
*<p>
* Well known request execution handlers could be referred to by name using one of the
* {@link ChainElement} enum values.
*</p>
*
* @since 4.3
* @see ChainElement
* @see HttpClientBuilder#addExecInterceptorFirst(String, ExecChainHandler)
* @see HttpClientBuilder#addExecInterceptorBefore(String, String, ExecChainHandler)
* @see HttpClientBuilder#addExecInterceptorAfter(String, String, ExecChainHandler)
* @see HttpClientBuilder#addExecInterceptorLast(String, ExecChainHandler)
*/
@Contract(threading = ThreadingBehavior.STATELESS)
public interface ExecChainHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.hc.client5.http.async.AsyncExecCallback;
import org.apache.hc.client5.http.async.AsyncExecChain;
import org.apache.hc.client5.http.async.AsyncExecChainHandler;
import org.apache.hc.client5.http.impl.ChainElement;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.Internal;
Expand Down Expand Up @@ -61,6 +62,22 @@
* endpoint is delegated to the next executor in the request execution
* chain.
* </p>
* <p>
* If this handler is active, pay particular attention to the placement
* of other handlers within the handler chain relative to the retry handler.
* Use {@link ChainElement#RETRY} as name when referring to this handler.
* </p>
* <p>
* If a custom handler is placed <b>before</b> the retry handler, the handler will
* see the initial request and the final outcome after the last retry. Elapsed time
* will account for any delays imposed by the retry handler.
* </p>
*
* <p>
* A custom handler which is placed <b>after</b> the retry handler will be invoked for
* each individual retry. Elapsed time will measure each individual http request,
* without the delay imposed by the retry handler.
* </p>
*
* @since 5.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.hc.client5.http.classic.ExecChain.Scope;
import org.apache.hc.client5.http.classic.ExecChainHandler;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.ChainElement;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.Internal;
Expand All @@ -61,6 +62,22 @@
* endpoint is delegated to the next executor in the request execution
* chain.
* </p>
* <p>
* If this handler is active, pay particular attention to the placement
* of other handlers within the handler chain relative to the retry handler.
* Use {@link ChainElement#RETRY} as name when referring to this handler.
* </p>
* <p>
* If a custom handler is placed <b>before</b> the retry handler, the handler will
* see the initial request and the final outcome after the last retry. Elapsed time
* will account for any delays imposed by the retry handler.
* </p>
*
* <p>
* A custom handler which is placed <b>after</b> the retry handler will be invoked for
* each individual retry. Elapsed time will measure each individual http request,
* without the delay imposed by the retry handler.
* </p>
*
* @since 5.0
*/
Expand Down

0 comments on commit 509ba67

Please sign in to comment.