Package io.servicetalk.http.api
Interface HttpExecutionStrategy
-
- All Superinterfaces:
ExecutionStrategy
- All Known Subinterfaces:
GrpcExecutionStrategy
- All Known Implementing Classes:
DelegatingHttpExecutionStrategy
public interface HttpExecutionStrategy extends ExecutionStrategy
An execution strategy for HTTP client and servers.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <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.StreamingHttpServiceoffloadService(Executor fallback, StreamingHttpService handler)Wraps the passedStreamingHttpServiceto apply thisHttpExecutionStrategy.-
Methods inherited from interface io.servicetalk.transport.api.ExecutionStrategy
executor, offloadReceive, offloadReceive, offloadSend, offloadSend
-
-
-
-
Method Detail
-
invokeClient
<FS> Single<StreamingHttpResponse> invokeClient(Executor fallback, Publisher<java.lang.Object> flattenedRequest, @Nullable FS flushStrategy, ClientInvoker<FS> client)
Invokes the passedFunctionand applies the necessary offloading of request and response for a client.- 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
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.- 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
<T> Single<T> invokeService(Executor fallback, java.util.function.Function<Executor,T> service)
Invokes 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).- 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
StreamingHttpService offloadService(Executor fallback, StreamingHttpService handler)
Wraps the passedStreamingHttpServiceto apply thisHttpExecutionStrategy.- Parameters:
fallback-Executorto use as a fallback if thisHttpExecutionStrategydoes not define anExecutor.handler-StreamingHttpServiceto wrap.- Returns:
- Wrapped
StreamingHttpService.
-
isMetadataReceiveOffloaded
boolean isMetadataReceiveOffloaded()
Returnstrueif metadata receive offloading is enabled for thisExecutionStrategy.- Returns:
trueif metadata receive offloading is enabled for thisExecutionStrategy.
-
isDataReceiveOffloaded
boolean isDataReceiveOffloaded()
Returnstrueif data receive offloading is enabled for thisExecutionStrategy.- Returns:
trueif data receive offloading is enabled for thisExecutionStrategy.
-
isSendOffloaded
boolean isSendOffloaded()
Returnstrueif send offloading is enabled for thisExecutionStrategy.- Returns:
trueif send offloading is enabled for thisExecutionStrategy.
-
merge
HttpExecutionStrategy merge(HttpExecutionStrategy other)
Merges the passedHttpExecutionStrategywiththisHttpExecutionStrategyand return the merged result.- Parameters:
other-HttpExecutionStrategyto merge withthis.- Returns:
- Merged
HttpExecutionStrategy.
-
-