Package io.servicetalk.http.api
Class DelegatingFilterableStreamingHttpLoadBalancedConnection
java.lang.Object
io.servicetalk.concurrent.api.DelegatingAsyncCloseable<T>
io.servicetalk.concurrent.api.DelegatingListenableAsyncCloseable<FilterableStreamingHttpLoadBalancedConnection>
io.servicetalk.http.api.DelegatingFilterableStreamingHttpLoadBalancedConnection
- All Implemented Interfaces:
LoadBalancedConnection,RequestConcurrencyController,ReservableRequestConcurrencyController,ScoreSupplier,AsyncCloseable,ListenableAsyncCloseable,GracefulAutoCloseable,FilterableReservedStreamingHttpConnection,FilterableStreamingHttpConnection,FilterableStreamingHttpLoadBalancedConnection,ReservedStreamingHttpConnection,StreamingHttpConnection,StreamingHttpRequester,StreamingHttpRequestFactory,AutoCloseable
public class DelegatingFilterableStreamingHttpLoadBalancedConnection
extends DelegatingListenableAsyncCloseable<FilterableStreamingHttpLoadBalancedConnection>
implements FilterableStreamingHttpLoadBalancedConnection
Implementation of
FilterableStreamingHttpLoadBalancedConnection that delegates all methods.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.servicetalk.client.api.RequestConcurrencyController
RequestConcurrencyController.Result -
Constructor Summary
ConstructorsConstructorDescriptionDelegatingFilterableStreamingHttpLoadBalancedConnection(FilterableStreamingHttpLoadBalancedConnection delegate) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidUsed to close/shutdown a resource, similar toAutoCloseable.close(), but attempts to cleanup state before abruptly closing.Create a newHttpRequestMethod.CONNECTrequest.Get theHttpConnectionContext.delegate()Get theFilterableStreamingHttpLoadBalancedConnectionthat this class delegates to.Create a newHttpRequestMethod.DELETErequest.Get theHttpExecutionContextused during construction of this object.Create a newHttpRequestMethod.GETrequest.Create a newHttpRequestMethod.HEADrequest.Get aStreamingHttpResponseFactory.newRequest(HttpRequestMethod method, String requestTarget) Create a newHttpRequestFactory.Create a newHttpRequestMethod.OPTIONSrequest.Create a newHttpRequestMethod.PATCHrequest.Create a newHttpRequestMethod.POSTrequest.Create a newHttpRequestMethod.PUTrequest.Must be called (and subscribed to) to signify the reservation has completed afterReservableRequestConcurrencyController.tryReserve().request(StreamingHttpRequest request) Send arequest.voidMust be called afterRequestConcurrencyController.tryRequest()to signify the request has completed.intscore()Returns the current score of a resource.toString()Create a newHttpRequestMethod.TRACErequest.<T> Publisher<? extends T>transportEventStream(HttpEventKey<T> eventKey) Returns aPublisherthat gives the current value of a transport event as well as subsequent changes to the event value as long as thePublisherSource.Subscriberhas expressed enough demand.Attempts to reserve a connection for a single request, needs to be followed byRequestConcurrencyController.requestFinished().booleanAttempts to reserve a connection for exclusive use untilReservableRequestConcurrencyController.releaseAsync()is called.Methods inherited from class io.servicetalk.concurrent.api.DelegatingListenableAsyncCloseable
onClose, onClosingMethods inherited from class io.servicetalk.concurrent.api.DelegatingAsyncCloseable
closeAsync, closeAsyncGracefullyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsync, closeAsyncGracefullyMethods inherited from interface io.servicetalk.http.api.FilterableStreamingHttpLoadBalancedConnection
asBlockingConnection, asBlockingStreamingConnection, asConnectionMethods inherited from interface io.servicetalk.concurrent.api.ListenableAsyncCloseable
onClose, onClosing
-
Constructor Details
-
DelegatingFilterableStreamingHttpLoadBalancedConnection
public DelegatingFilterableStreamingHttpLoadBalancedConnection(FilterableStreamingHttpLoadBalancedConnection delegate) Create a new instance.- Parameters:
delegate- The instance to delegate to.
-
-
Method Details
-
delegate
Get theFilterableStreamingHttpLoadBalancedConnectionthat this class delegates to.- Overrides:
delegatein classDelegatingListenableAsyncCloseable<FilterableStreamingHttpLoadBalancedConnection>- Returns:
- the
FilterableStreamingHttpLoadBalancedConnectionthat this class delegates to.
-
tryRequest
Description copied from interface:RequestConcurrencyControllerAttempts to reserve a connection for a single request, needs to be followed byRequestConcurrencyController.requestFinished().- Specified by:
tryRequestin interfaceLoadBalancedConnection- Specified by:
tryRequestin interfaceRequestConcurrencyController- Returns:
RequestConcurrencyController.Result.Acceptedif this connection is available and reserved for performing a single request.
-
requestFinished
public void requestFinished()Description copied from interface:RequestConcurrencyControllerMust be called afterRequestConcurrencyController.tryRequest()to signify the request has completed. This method should be called no more than once for each call toRequestConcurrencyController.tryRequest().Generally called from a
Publisher.beforeFinally(Runnable)after aRequestConcurrencyController.tryRequest().- Specified by:
requestFinishedin interfaceLoadBalancedConnection- Specified by:
requestFinishedin interfaceRequestConcurrencyController
-
tryReserve
public boolean tryReserve()Description copied from interface:ReservableRequestConcurrencyControllerAttempts to reserve a connection for exclusive use untilReservableRequestConcurrencyController.releaseAsync()is called.- Specified by:
tryReservein interfaceLoadBalancedConnection- Specified by:
tryReservein interfaceReservableRequestConcurrencyController- Returns:
trueif this connection is available and reserved for performing a single request.
-
score
public int score()Description copied from interface:ScoreSupplierReturns the current score of a resource.LoadBalancers prefer resources with a higher score.- Specified by:
scorein interfaceScoreSupplier- Returns:
- the score
-
connectionContext
Description copied from interface:FilterableStreamingHttpConnectionGet theHttpConnectionContext.- Specified by:
connectionContextin interfaceFilterableStreamingHttpConnection- Returns:
- the
HttpConnectionContext.
-
transportEventStream
Description copied from interface:FilterableStreamingHttpConnectionReturns aPublisherthat gives the current value of a transport event as well as subsequent changes to the event value as long as thePublisherSource.Subscriberhas expressed enough demand.This is designed for events produced by the transport, and consumed by filters interested in transport behavior which is not directly involved in the data path.
- Specified by:
transportEventStreamin interfaceFilterableStreamingHttpConnection- Type Parameters:
T- Type of the event value.- Parameters:
eventKey- Name of the event to fetch.- Returns:
Publisherfor the event values.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStreamingHttpRequester- Throws:
Exception
-
closeGracefully
Description copied from interface:GracefulAutoCloseableUsed to close/shutdown a resource, similar toAutoCloseable.close(), 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 toAutoCloseable.close().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
AutoCloseable.close().- Specified by:
closeGracefullyin interfaceGracefulAutoCloseable- Specified by:
closeGracefullyin interfaceStreamingHttpRequester- Throws:
Exception- if graceful closure failed.
-
releaseAsync
Description copied from interface:ReservableRequestConcurrencyControllerMust be called (and subscribed to) to signify the reservation has completed afterReservableRequestConcurrencyController.tryReserve().- Specified by:
releaseAsyncin interfaceFilterableReservedStreamingHttpConnection- Specified by:
releaseAsyncin interfaceFilterableStreamingHttpLoadBalancedConnection- Specified by:
releaseAsyncin interfaceLoadBalancedConnection- Specified by:
releaseAsyncin interfaceReservableRequestConcurrencyController- Returns:
- a
Completablefor the release.
-
newRequest
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestFactory.- Specified by:
newRequestin interfaceStreamingHttpRequestFactory- Parameters:
method- TheHttpRequestMethod.requestTarget- The request target.- Returns:
- a new
HttpRequestFactory.
-
get
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.GETrequest.- Specified by:
getin interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.GETrequest.
-
post
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.POSTrequest.- Specified by:
postin interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.POSTrequest.
-
put
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.PUTrequest.- Specified by:
putin interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.PUTrequest.
-
options
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.OPTIONSrequest.- Specified by:
optionsin interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.OPTIONSrequest.
-
head
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.HEADrequest.- Specified by:
headin interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.HEADrequest.
-
trace
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.TRACErequest.- Specified by:
tracein interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.TRACErequest.
-
delete
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.DELETErequest.- Specified by:
deletein interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.DELETErequest.
-
patch
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.PATCHrequest.- Specified by:
patchin interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.PATCHrequest.
-
connect
Description copied from interface:StreamingHttpRequestFactoryCreate a newHttpRequestMethod.CONNECTrequest.- Specified by:
connectin interfaceStreamingHttpRequestFactory- Parameters:
requestTarget- The request target.- Returns:
- a new
HttpRequestMethod.CONNECTrequest.
-
request
Description copied from interface:StreamingHttpRequesterSend arequest.- Specified by:
requestin interfaceStreamingHttpRequester- Parameters:
request- the request to send.- Returns:
- The response.
-
executionContext
Description copied from interface:StreamingHttpRequesterGet theHttpExecutionContextused during construction of this object.Note that the
ExecutionContext.ioExecutor()will not necessarily be associated with a specific thread unless that was how this object was built.- Specified by:
executionContextin interfaceStreamingHttpRequester- Returns:
- the
HttpExecutionContextused during construction of this object.
-
httpResponseFactory
Description copied from interface:StreamingHttpRequesterGet aStreamingHttpResponseFactory.- Specified by:
httpResponseFactoryin interfaceStreamingHttpRequester- Returns:
- a
StreamingHttpResponseFactory.
-
toString
- Overrides:
toStringin classDelegatingAsyncCloseable<FilterableStreamingHttpLoadBalancedConnection>
-