Interface Endpoint<A extends ExchangeContext>

Type Parameters:
A - the exchange context type

public interface Endpoint<A extends ExchangeContext>

An endpoint represents the terminal end in an HTTP communication from a client to a server.

It is obtained from the HttpClient and it is bound to an IP Socket Address of an HTTP server. It exposes methods to create HTTP client Exchange used to create and send HTTP requests or open Web sockets.

Since:
1.6
Author:
Jeremy Kuhn
  • Method Details

    • getLocalAddress

      SocketAddress getLocalAddress()

      Returns the local socket address of the endpoint.

      Returns:
      a socket address
    • getRemoteAddress

      SocketAddress getRemoteAddress()

      Returns the remote socket address of the endpoint.

      Returns:
      a socket address
    • getActiveRequests

      long getActiveRequests()

      Returns the current number of active requests handled by this endpoint.

      The returned value includes all active connection requests: connecting, requesting, buffered...

      Returns:
      the number of active requests.
    • getLoadFactor

      float getLoadFactor()

      Returns the current load factor of the endpoint between 0 (not loaded) and 1 (loaded at maximum capacity and buffering requests).

      The returned value shall consider the max number of connections handled by the endpoint to properly represent its available capacity.

      Returns:
      the load factor between 0 and 1
    • exchange

      default Mono<? extends Exchange<A>> exchange()

      Creates an HTTP exchange.

      This method is a shortcut for exchange(Method.GET, "/", null).

      Returns:
      an HTTP exchange mono
    • exchange

      default Mono<? extends Exchange<A>> exchange(A context)

      Creates an HTTP exchange.

      This method is a shortcut for exchange(Method.GET, "/", context).

      Parameters:
      context - the exchange context
      Returns:
      an HTTP exchange mono
    • exchange

      default Mono<? extends Exchange<A>> exchange(String requestTarget)

      Creates an HTTP exchange.

      This method is a shortcut for exchange(Method.GET, requestTarget, null).

      Parameters:
      requestTarget - the request target path
      Returns:
      an HTTP exchange mono
    • exchange

      default Mono<? extends Exchange<A>> exchange(String requestTarget, A context)

      Creates an HTTP exchange.

      This method is a shortcut for exchange(Method.GET, requestTarget, context).

      Parameters:
      requestTarget - the request target path
      context - the exchange context
      Returns:
      an HTTP exchange mono
    • exchange

      default Mono<? extends Exchange<A>> exchange(Method method, String requestTarget)

      Creates an HTTP exchange.

      This method is a shortcut for exchange(method, requestTarget, null).

      Parameters:
      method - the HTTP method
      requestTarget - the request target path
      Returns:
      an HTTP exchange mono
    • exchange

      Mono<? extends Exchange<A>> exchange(Method method, String requestTarget, A context) throws IllegalArgumentException

      Creates an HTTP exchange with a context.

      Parameters:
      method - the HTTP method
      requestTarget - the request target path
      context - the exchange context
      Returns:
      an HTTP exchange mono
      Throws:
      IllegalArgumentException - if the specified request target is invalid
    • shutdown

      Mono<Void> shutdown()

      Shutdowns the endpoint right away.

      This is a hard shutdown that closes all active connections right away.

      Note that detached connections (e.g. WebSocket) are not considered here and must be closed individually.

      Returns:
      a mono which completes once the endpoint is shutdown
    • shutdownGracefully

      Mono<Void> shutdownGracefully()

      Gracefully shutdowns the endpoint.

      This is a graceful shutdown that waits for all active exchanges to complete before shutting down the connections.

      Note that detached connections (e.g. WebSocket) are not considered here and must be closed individually.

      Returns:
      a mono which completes once the endpoint is shutdown
      See Also: