Package io.servicetalk.http.api
Class StreamingHttpServiceToOffloadedStreamingHttpService
java.lang.Object
io.servicetalk.http.api.StreamingHttpServiceToOffloadedStreamingHttpService
- All Implemented Interfaces:
AsyncCloseable
,HttpExecutionStrategyInfluencer
,HttpServiceBase
,StreamingHttpService
,ExecutionStrategyInfluencer<HttpExecutionStrategy>
public class StreamingHttpServiceToOffloadedStreamingHttpService
extends Object
implements StreamingHttpService
Wraps a
StreamingHttpService
to apply the provided HttpExecutionStrategy
and Executor
for
offloading.-
Method Summary
Modifier and TypeMethodDescriptionCloses thisStreamingHttpService
asynchronously.Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync()
, but attempts to cleanup state before abruptly closing.handle
(HttpServiceContext ctx, StreamingHttpRequest request, StreamingHttpResponseFactory responseFactory) Handles a single HTTP request.static StreamingHttpService
offloadService
(HttpExecutionStrategy strategy, Executor executor, BooleanSupplier shouldOffload, StreamingHttpService service) Wraps the passedStreamingHttpServiceToOffloadedStreamingHttpService
to apply the providedHttpExecutionStrategy
for offloading.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.servicetalk.http.api.HttpExecutionStrategyInfluencer
influenceStrategy
Methods inherited from interface io.servicetalk.http.api.StreamingHttpService
requiredOffloads
-
Method Details
-
handle
public Single<StreamingHttpResponse> handle(HttpServiceContext ctx, StreamingHttpRequest request, StreamingHttpResponseFactory responseFactory) Description copied from interface:StreamingHttpService
Handles a single HTTP request.- Specified by:
handle
in interfaceStreamingHttpService
- Parameters:
ctx
- Context of the service.request
- to handle.responseFactory
- used to createStreamingHttpResponse
objects.- Returns:
Single
of HTTP response.
-
closeAsync
Description copied from interface:StreamingHttpService
Closes thisStreamingHttpService
asynchronously.- Specified by:
closeAsync
in interfaceAsyncCloseable
- Specified by:
closeAsync
in interfaceStreamingHttpService
- Returns:
Completable
that when subscribed will close thisStreamingHttpService
.
-
closeAsyncGracefully
Description copied from interface:AsyncCloseable
Used to close/shutdown a resource, similar toAsyncCloseable.closeAsync()
, but attempts to cleanup state before abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in flight work. This method is implemented on a "best effort" basis and may be equivalent toAsyncCloseable.closeAsync()
.Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a timeout and force a call to
AsyncCloseable.closeAsync()
.- Specified by:
closeAsyncGracefully
in interfaceAsyncCloseable
- Returns:
- A
Completable
that is notified once the close is complete.
-
offloadService
public static StreamingHttpService offloadService(HttpExecutionStrategy strategy, @Nullable Executor executor, BooleanSupplier shouldOffload, StreamingHttpService service) Wraps the passedStreamingHttpServiceToOffloadedStreamingHttpService
to apply the providedHttpExecutionStrategy
for offloading.- Parameters:
strategy
-HttpExecutionStrategy
to use for offloading.executor
-Executor
to use as executor ornull
to use Execution context executor.shouldOffload
- IfBooleanSupplier
returnstrue
then offload to executor otherwise continue execution on calling thread.service
-StreamingHttpServiceToOffloadedStreamingHttpService
to wrap.- Returns:
- Wrapped
StreamingHttpServiceToOffloadedStreamingHttpService
.
-