Package io.servicetalk.http.api
Class DelegatingHttpExecutionStrategy
- java.lang.Object
-
- io.servicetalk.http.api.DelegatingHttpExecutionStrategy
-
- All Implemented Interfaces:
HttpExecutionStrategy,ExecutionStrategy
public class DelegatingHttpExecutionStrategy extends java.lang.Object implements HttpExecutionStrategy
AnHttpExecutionStrategythat delegates all method calls to anotherHttpExecutionStrategy.
-
-
Constructor Summary
Constructors Constructor Description DelegatingHttpExecutionStrategy(HttpExecutionStrategy delegate)Create a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Executorexecutor()Returns theExecutor, if any for thisExecutionStrategy.inthashCode()<FS> Single<StreamingHttpResponse>invokeClient(Executor fallback, Publisher<java.lang.Object> flattenedRequest, FS flushStrategy, ClientInvoker<FS> client)Invokes the passedFunctionand applies the necessary offloading of request and response for a client.Publisher<java.lang.Object>invokeService(Executor fallback, StreamingHttpRequest request, java.util.function.Function<StreamingHttpRequest,Publisher<java.lang.Object>> service, java.util.function.BiFunction<java.lang.Throwable,Executor,Publisher<java.lang.Object>> errorHandler)Invokes the passedFunctionand applies the necessary offloading of request and response for a server.<T> Single<T>invokeService(Executor fallback, java.util.function.Function<Executor,T> service)Invokes a service represented by the passedFunction.booleanisDataReceiveOffloaded()Returnstrueif data receive offloading is enabled for thisExecutionStrategy.booleanisMetadataReceiveOffloaded()Returnstrueif metadata receive offloading is enabled for thisExecutionStrategy.booleanisSendOffloaded()Returnstrueif send offloading is enabled for thisExecutionStrategy.HttpExecutionStrategymerge(HttpExecutionStrategy other)Merges the passedHttpExecutionStrategywiththisHttpExecutionStrategyand return the merged result.<T> Publisher<T>offloadReceive(Executor fallback, Publisher<T> original)Offloads theoriginalPublisherfor receiving data from the transport.<T> Single<T>offloadReceive(Executor fallback, Single<T> original)Offloads theoriginalSinglefor receiving data from the transport.<T> Publisher<T>offloadSend(Executor fallback, Publisher<T> original)Offloads theoriginalPublisherfor sending data on the transport.<T> Single<T>offloadSend(Executor fallback, Single<T> original)Offloads theoriginalSinglefor sending data on the transport.StreamingHttpServiceoffloadService(Executor fallback, StreamingHttpService handler)Wraps the passedStreamingHttpServiceto apply thisHttpExecutionStrategy.
-
-
-
Constructor Detail
-
DelegatingHttpExecutionStrategy
public DelegatingHttpExecutionStrategy(HttpExecutionStrategy delegate)
Create a new instance.- Parameters:
delegate-HttpExecutionStrategyto which all method calls will be delegated.
-
-
Method Detail
-
invokeClient
public <FS> Single<StreamingHttpResponse> invokeClient(Executor fallback, Publisher<java.lang.Object> flattenedRequest, FS flushStrategy, ClientInvoker<FS> client)
Description copied from interface:HttpExecutionStrategyInvokes the passedFunctionand applies the necessary offloading of request and response for a client.- Specified by:
invokeClientin interfaceHttpExecutionStrategy- Type Parameters:
FS- TheFlushStrategytype to use.- Parameters:
fallback-Executorto use as a fallback if thisHttpExecutionStrategydoes not define anExecutor.flattenedRequest- A flattenedPublishercontaining all data constituting an HTTP request.flushStrategy- TheFlushStrategyto use.client- ABiFunctionthat given flattened stream ofHttpRequestMetaData, payload and trailers, for the passedStreamingHttpRequestreturns aSingle.- Returns:
Singlewhich is offloaded as required.
-
invokeService
public Publisher<java.lang.Object> invokeService(Executor fallback, StreamingHttpRequest request, java.util.function.Function<StreamingHttpRequest,Publisher<java.lang.Object>> service, java.util.function.BiFunction<java.lang.Throwable,Executor,Publisher<java.lang.Object>> errorHandler)
Description copied from interface:HttpExecutionStrategyInvokes the passedFunctionand applies the necessary offloading of request and response for a server.- Specified by:
invokeServicein interfaceHttpExecutionStrategy- Parameters:
fallback-Executorto use as a fallback if thisHttpExecutionStrategydoes not define anExecutor.request-StreamingHttpRequestfor which the offloading is to be applied.service- AFunctionthat executes aStreamingHttpRequestand returns a flattenedPublishercontaining all data constituting an HTTP response.errorHandler- In case there is an error before calling the passedservice, thisBiFunctionwill be called to generate an error response.- Returns:
- A flattened
Publishercontaining all data constituting an HTTP response..
-
invokeService
public <T> Single<T> invokeService(Executor fallback, java.util.function.Function<Executor,T> service)
Description copied from interface:HttpExecutionStrategyInvokes a service represented by the passedFunction.This method does not apply the strategy on the object returned from the
Function, if that object is an asynchronous source then the caller of this method should take care and offload that source usingExecutionStrategy.offloadSend(Executor, Single)orExecutionStrategy.offloadSend(Executor, Publisher).- Specified by:
invokeServicein interfaceHttpExecutionStrategy- Type Parameters:
T- Type of result of the invocation of the service.- Parameters:
fallback-Executorto use as a fallback if thisHttpExecutionStrategydoes not define anExecutor.service-Functionrepresenting a service.- Returns:
- A
Singlethat invokes the passedFunctionand returns the result asynchronously. Invocation ofFunctionwill be offloaded if configured.
-
offloadService
public StreamingHttpService offloadService(Executor fallback, StreamingHttpService handler)
Description copied from interface:HttpExecutionStrategyWraps the passedStreamingHttpServiceto apply thisHttpExecutionStrategy.- Specified by:
offloadServicein interfaceHttpExecutionStrategy- Parameters:
fallback-Executorto use as a fallback if thisHttpExecutionStrategydoes not define anExecutor.handler-StreamingHttpServiceto wrap.- Returns:
- Wrapped
StreamingHttpService.
-
isMetadataReceiveOffloaded
public boolean isMetadataReceiveOffloaded()
Description copied from interface:HttpExecutionStrategyReturnstrueif metadata receive offloading is enabled for thisExecutionStrategy.- Specified by:
isMetadataReceiveOffloadedin interfaceHttpExecutionStrategy- Returns:
trueif metadata receive offloading is enabled for thisExecutionStrategy.
-
isDataReceiveOffloaded
public boolean isDataReceiveOffloaded()
Description copied from interface:HttpExecutionStrategyReturnstrueif data receive offloading is enabled for thisExecutionStrategy.- Specified by:
isDataReceiveOffloadedin interfaceHttpExecutionStrategy- Returns:
trueif data receive offloading is enabled for thisExecutionStrategy.
-
isSendOffloaded
public boolean isSendOffloaded()
Description copied from interface:HttpExecutionStrategyReturnstrueif send offloading is enabled for thisExecutionStrategy.- Specified by:
isSendOffloadedin interfaceHttpExecutionStrategy- Returns:
trueif send offloading is enabled for thisExecutionStrategy.
-
merge
public HttpExecutionStrategy merge(HttpExecutionStrategy other)
Description copied from interface:HttpExecutionStrategyMerges the passedHttpExecutionStrategywiththisHttpExecutionStrategyand return the merged result.- Specified by:
mergein interfaceHttpExecutionStrategy- Parameters:
other-HttpExecutionStrategyto merge withthis.- Returns:
- Merged
HttpExecutionStrategy.
-
offloadSend
public <T> Single<T> offloadSend(Executor fallback, Single<T> original)
Description copied from interface:ExecutionStrategyOffloads theoriginalSinglefor sending data on the transport.- Specified by:
offloadSendin interfaceExecutionStrategy- Type Parameters:
T- Type of result of theoriginalSingle.- Parameters:
fallback-Executorto use as a fallback if thisExecutionStrategydoes not define anExecutor.original-Singleto offload.- Returns:
- Offloaded
Single.
-
offloadReceive
public <T> Single<T> offloadReceive(Executor fallback, Single<T> original)
Description copied from interface:ExecutionStrategyOffloads theoriginalSinglefor receiving data from the transport.- Specified by:
offloadReceivein interfaceExecutionStrategy- Type Parameters:
T- Type of result of theoriginalSingle.- Parameters:
fallback-Executorto use as a fallback if thisExecutionStrategydoes not define anExecutor.original-Singleto offload.- Returns:
- Offloaded
Single.
-
offloadSend
public <T> Publisher<T> offloadSend(Executor fallback, Publisher<T> original)
Description copied from interface:ExecutionStrategyOffloads theoriginalPublisherfor sending data on the transport.- Specified by:
offloadSendin interfaceExecutionStrategy- Type Parameters:
T- Type of items emitted from theoriginalPublisher.- Parameters:
fallback-Executorto use as a fallback if thisExecutionStrategydoes not define anExecutor.original-Publisherto offload.- Returns:
- Offloaded
Publisher.
-
offloadReceive
public <T> Publisher<T> offloadReceive(Executor fallback, Publisher<T> original)
Description copied from interface:ExecutionStrategyOffloads theoriginalPublisherfor receiving data from the transport.- Specified by:
offloadReceivein interfaceExecutionStrategy- Type Parameters:
T- Type of items emitted from theoriginalPublisher.- Parameters:
fallback-Executorto use as a fallback if thisExecutionStrategydoes not define anExecutor.original-Publisherto offload.- Returns:
- Offloaded
Publisher.
-
executor
@Nullable public Executor executor()
Description copied from interface:ExecutionStrategyReturns theExecutor, if any for thisExecutionStrategy.- Specified by:
executorin interfaceExecutionStrategy- Returns:
Executorfor thisExecutionStrategy.nullif none specified.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-