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
AnHttpExecutionStrategy
that 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 boolean
equals(java.lang.Object o)
Executor
executor()
Returns theExecutor
, if any for thisExecutionStrategy
.int
hashCode()
<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.<T> Publisher<T>
offloadReceive(Executor fallback, Publisher<T> original)
Offloads theoriginal
Publisher
for receiving data from the transport.<T> Single<T>
offloadReceive(Executor fallback, Single<T> original)
Offloads theoriginal
Single
for receiving data from the transport.<T> Publisher<T>
offloadSend(Executor fallback, Publisher<T> original)
Offloads theoriginal
Publisher
for sending data on the transport.<T> Single<T>
offloadSend(Executor fallback, Single<T> original)
Offloads theoriginal
Single
for sending data on the transport.StreamingHttpService
offloadService(Executor fallback, StreamingHttpService handler)
Wraps the passedStreamingHttpService
to apply thisHttpExecutionStrategy
.
-
-
-
Constructor Detail
-
DelegatingHttpExecutionStrategy
public DelegatingHttpExecutionStrategy(HttpExecutionStrategy delegate)
Create a new instance.- Parameters:
delegate
-HttpExecutionStrategy
to 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:HttpExecutionStrategy
Invokes the passedFunction
and applies the necessary offloading of request and response for a client.- Specified by:
invokeClient
in interfaceHttpExecutionStrategy
- 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
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:HttpExecutionStrategy
Invokes the passedFunction
and applies the necessary offloading of request and response for a server.- Specified by:
invokeService
in interfaceHttpExecutionStrategy
- 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
public <T> Single<T> invokeService(Executor fallback, java.util.function.Function<Executor,T> service)
Description copied from interface:HttpExecutionStrategy
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)
.- Specified by:
invokeService
in interfaceHttpExecutionStrategy
- 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
public StreamingHttpService offloadService(Executor fallback, StreamingHttpService handler)
Description copied from interface:HttpExecutionStrategy
Wraps the passedStreamingHttpService
to apply thisHttpExecutionStrategy
.- Specified by:
offloadService
in interfaceHttpExecutionStrategy
- Parameters:
fallback
-Executor
to use as a fallback if thisHttpExecutionStrategy
does not define anExecutor
.handler
-StreamingHttpService
to wrap.- Returns:
- Wrapped
StreamingHttpService
.
-
isMetadataReceiveOffloaded
public boolean isMetadataReceiveOffloaded()
Description copied from interface:HttpExecutionStrategy
Returnstrue
if metadata receive offloading is enabled for thisExecutionStrategy
.- Specified by:
isMetadataReceiveOffloaded
in interfaceHttpExecutionStrategy
- Returns:
true
if metadata receive offloading is enabled for thisExecutionStrategy
.
-
isDataReceiveOffloaded
public boolean isDataReceiveOffloaded()
Description copied from interface:HttpExecutionStrategy
Returnstrue
if data receive offloading is enabled for thisExecutionStrategy
.- Specified by:
isDataReceiveOffloaded
in interfaceHttpExecutionStrategy
- Returns:
true
if data receive offloading is enabled for thisExecutionStrategy
.
-
isSendOffloaded
public boolean isSendOffloaded()
Description copied from interface:HttpExecutionStrategy
Returnstrue
if send offloading is enabled for thisExecutionStrategy
.- Specified by:
isSendOffloaded
in interfaceHttpExecutionStrategy
- Returns:
true
if send offloading is enabled for thisExecutionStrategy
.
-
merge
public HttpExecutionStrategy merge(HttpExecutionStrategy other)
Description copied from interface:HttpExecutionStrategy
Merges the passedHttpExecutionStrategy
withthis
HttpExecutionStrategy
and return the merged result.- Specified by:
merge
in interfaceHttpExecutionStrategy
- Parameters:
other
-HttpExecutionStrategy
to merge withthis
.- Returns:
- Merged
HttpExecutionStrategy
.
-
offloadSend
public <T> Single<T> offloadSend(Executor fallback, Single<T> original)
Description copied from interface:ExecutionStrategy
Offloads theoriginal
Single
for sending data on the transport.- Specified by:
offloadSend
in interfaceExecutionStrategy
- Type Parameters:
T
- Type of result of theoriginal
Single
.- Parameters:
fallback
-Executor
to use as a fallback if thisExecutionStrategy
does not define anExecutor
.original
-Single
to offload.- Returns:
- Offloaded
Single
.
-
offloadReceive
public <T> Single<T> offloadReceive(Executor fallback, Single<T> original)
Description copied from interface:ExecutionStrategy
Offloads theoriginal
Single
for receiving data from the transport.- Specified by:
offloadReceive
in interfaceExecutionStrategy
- Type Parameters:
T
- Type of result of theoriginal
Single
.- Parameters:
fallback
-Executor
to use as a fallback if thisExecutionStrategy
does not define anExecutor
.original
-Single
to offload.- Returns:
- Offloaded
Single
.
-
offloadSend
public <T> Publisher<T> offloadSend(Executor fallback, Publisher<T> original)
Description copied from interface:ExecutionStrategy
Offloads theoriginal
Publisher
for sending data on the transport.- Specified by:
offloadSend
in interfaceExecutionStrategy
- Type Parameters:
T
- Type of items emitted from theoriginal
Publisher
.- Parameters:
fallback
-Executor
to use as a fallback if thisExecutionStrategy
does not define anExecutor
.original
-Publisher
to offload.- Returns:
- Offloaded
Publisher
.
-
offloadReceive
public <T> Publisher<T> offloadReceive(Executor fallback, Publisher<T> original)
Description copied from interface:ExecutionStrategy
Offloads theoriginal
Publisher
for receiving data from the transport.- Specified by:
offloadReceive
in interfaceExecutionStrategy
- Type Parameters:
T
- Type of items emitted from theoriginal
Publisher
.- Parameters:
fallback
-Executor
to use as a fallback if thisExecutionStrategy
does not define anExecutor
.original
-Publisher
to offload.- Returns:
- Offloaded
Publisher
.
-
executor
@Nullable public Executor executor()
Description copied from interface:ExecutionStrategy
Returns theExecutor
, if any for thisExecutionStrategy
.- Specified by:
executor
in interfaceExecutionStrategy
- Returns:
Executor
for thisExecutionStrategy
.null
if none specified.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-