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 passedFunction
and 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 passedFunction
and 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
.boolean
isDataReceiveOffloaded()
Returnstrue
if data receive offloading is enabled for thisExecutionStrategy
.boolean
isMetadataReceiveOffloaded()
Returnstrue
if metadata receive offloading is enabled for thisExecutionStrategy
.boolean
isSendOffloaded()
Returnstrue
if send offloading is enabled for thisExecutionStrategy
.HttpExecutionStrategy
merge(HttpExecutionStrategy other)
Merges the passedHttpExecutionStrategy
withthis
HttpExecutionStrategy
and return the merged result.StreamingHttpService
offloadService(Executor fallback, StreamingHttpService handler)
Wraps the passedStreamingHttpService
to 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 passedFunction
and applies the necessary offloading of request and response for a client.- Type Parameters:
FS
- TheFlushStrategy
type to use.- Parameters:
fallback
-Executor
to use as a fallback if thisHttpExecutionStrategy
does not define anExecutor
.flattenedRequest
- A flattenedPublisher
containing all data constituting an HTTP request.flushStrategy
- TheFlushStrategy
to use.client
- ABiFunction
that given flattened stream ofHttpRequestMetaData
, payload and trailers, for the passedStreamingHttpRequest
returns aSingle
.- Returns:
Single
which 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 passedFunction
and applies the necessary offloading of request and response for a server.- Parameters:
fallback
-Executor
to use as a fallback if thisHttpExecutionStrategy
does not define anExecutor
.request
-StreamingHttpRequest
for which the offloading is to be applied.service
- AFunction
that executes aStreamingHttpRequest
and returns a flattenedPublisher
containing all data constituting an HTTP response.errorHandler
- In case there is an error before calling the passedservice
, thisBiFunction
will be called to generate an error response.- Returns:
- A flattened
Publisher
containing 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
-Executor
to use as a fallback if thisHttpExecutionStrategy
does not define anExecutor
.service
-Function
representing a service.- Returns:
- A
Single
that invokes the passedFunction
and returns the result asynchronously. Invocation ofFunction
will be offloaded if configured.
-
offloadService
StreamingHttpService offloadService(Executor fallback, StreamingHttpService handler)
Wraps the passedStreamingHttpService
to apply thisHttpExecutionStrategy
.- Parameters:
fallback
-Executor
to use as a fallback if thisHttpExecutionStrategy
does not define anExecutor
.handler
-StreamingHttpService
to wrap.- Returns:
- Wrapped
StreamingHttpService
.
-
isMetadataReceiveOffloaded
boolean isMetadataReceiveOffloaded()
Returnstrue
if metadata receive offloading is enabled for thisExecutionStrategy
.- Returns:
true
if metadata receive offloading is enabled for thisExecutionStrategy
.
-
isDataReceiveOffloaded
boolean isDataReceiveOffloaded()
Returnstrue
if data receive offloading is enabled for thisExecutionStrategy
.- Returns:
true
if data receive offloading is enabled for thisExecutionStrategy
.
-
isSendOffloaded
boolean isSendOffloaded()
Returnstrue
if send offloading is enabled for thisExecutionStrategy
.- Returns:
true
if send offloading is enabled for thisExecutionStrategy
.
-
merge
HttpExecutionStrategy merge(HttpExecutionStrategy other)
Merges the passedHttpExecutionStrategy
withthis
HttpExecutionStrategy
and return the merged result.- Parameters:
other
-HttpExecutionStrategy
to merge withthis
.- Returns:
- Merged
HttpExecutionStrategy
.
-
-