Interface Client<I extends Request,O extends Response>

Type Parameters:
I - the type of outgoing Request. Must be HttpRequest or RpcRequest.
O - the type of incoming Response. Must be HttpResponse or RpcResponse.
All Superinterfaces:
Unwrappable
All Known Subinterfaces:
HttpClient, RpcClient
All Known Implementing Classes:
AbstractCircuitBreakerClient, AbstractConcurrencyLimitingClient, AbstractRetryingClient, BraveClient, CircuitBreakerClient, CircuitBreakerRpcClient, ConcurrencyLimitingClient, ContentPreviewingClient, CookieClient, DecodingClient, DecoratingClient, LoggingClient, LoggingRpcClient, MetricCollectingClient, MetricCollectingRpcClient, OAuth2Client, ObservationClient, RetryingClient, RetryingRpcClient, SimpleDecoratingClient, SimpleDecoratingHttpClient, SimpleDecoratingRpcClient
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Client<I extends Request,O extends Response> extends Unwrappable
Sends a Request to a remote Endpoint.

Note that this interface is not a user's entry point for sending a Request. It is rather a generic request processor interface implemented by a DecoratingClient, which intercepts a Request. A user is supposed to make his or her Request via the object returned by a ClientBuilder or Clients, which usually does not implement this interface.

See Also:
  • Method Details

    • execute

      O execute(ClientRequestContext ctx, I req) throws Exception
      Sends a Request to a remote Endpoint, as specified in ClientRequestContext.endpoint().
      Returns:
      the Response to the specified Request
      Throws:
      Exception
    • as

      default <T> T as(Class<T> type)
      Unwraps this Client into the object of the specified type. Use this method instead of an explicit downcast. For example:
      
       WebClient client = WebClient.builder(...)
                                   .decorator(LoggingClient.newDecorator())
                                   .build();
      
       LoggingClient unwrapped = client.as(LoggingClient.class);
      
       // You can also use Clients.unwrap(), which is useful especially for
       // Thrift and gRPC where the client object does not implement the 'as()' method.
       LoggingClient unwrapped2 = Clients.unwrap(client, LoggingClient.class);
       
      Specified by:
      as in interface Unwrappable
      Parameters:
      type - the type of the object to return
      Returns:
      the object of the specified type if found, or null if not found.
      See Also:
    • unwrap

      default Client<? extends Request,? extends Response> unwrap()
      Unwraps this Client and returns the object being decorated. If this Client is the innermost object, this method returns itself.
      Specified by:
      unwrap in interface Unwrappable