Package io.servicetalk.http.api
Interface HttpConnection
- All Superinterfaces:
AsyncCloseable
,AutoCloseable
,GracefulAutoCloseable
,HttpRequester
,HttpRequestFactory
,ListenableAsyncCloseable
- All Known Subinterfaces:
ReservedHttpConnection
Represents a single fixed connection to a HTTP server.
-
Method Summary
Modifier and TypeMethodDescriptiondefault BlockingHttpConnection
Convert thisHttpConnection
to theBlockingHttpConnection
API.default BlockingStreamingHttpConnection
Convert thisHttpConnection
to theBlockingStreamingHttpConnection
API.Convert thisHttpConnection
to theStreamingHttpConnection
API.default void
close()
default void
Used to close/shutdown a resource, similar toAutoCloseable.close()
, but attempts to cleanup state before abruptly closing.Get theHttpConnectionContext
.<T> Publisher<? extends T>
transportEventStream
(HttpEventKey<T> eventKey) Returns aPublisher
that gives the current value of a transport event as well as subsequent changes to the event value as long as thePublisherSource.Subscriber
has expressed enough demand.Methods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsync, closeAsyncGracefully
Methods inherited from interface io.servicetalk.http.api.HttpRequester
executionContext, httpResponseFactory, request
Methods inherited from interface io.servicetalk.http.api.HttpRequestFactory
connect, delete, get, head, newRequest, options, patch, post, put, trace
Methods inherited from interface io.servicetalk.concurrent.api.ListenableAsyncCloseable
onClose, onClosing
-
Method Details
-
connectionContext
HttpConnectionContext connectionContext()Get theHttpConnectionContext
.- Returns:
- the
HttpConnectionContext
.
-
transportEventStream
Returns aPublisher
that gives the current value of a transport event as well as subsequent changes to the event value as long as thePublisherSource.Subscriber
has 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.
- Type Parameters:
T
- Type of the event value.- Parameters:
eventKey
- Name of the event to fetch.- Returns:
Publisher
for the event values.
-
asStreamingConnection
StreamingHttpConnection asStreamingConnection()Convert thisHttpConnection
to theStreamingHttpConnection
API.- Returns:
- a
StreamingHttpConnection
representation of thisHttpConnection
.
-
asBlockingStreamingConnection
Convert thisHttpConnection
to theBlockingStreamingHttpConnection
API.- Returns:
- a
BlockingStreamingHttpConnection
representation of thisHttpConnection
.
-
asBlockingConnection
Convert thisHttpConnection
to theBlockingHttpConnection
API.- Returns:
- a
BlockingHttpConnection
representation of thisHttpConnection
.
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
closeGracefully
Description copied from interface:GracefulAutoCloseable
Used 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:
closeGracefully
in interfaceGracefulAutoCloseable
- Throws:
Exception
- if graceful closure failed.
-