I - the type of outgoing Request. Must be HttpRequest or RpcRequest.O - the type of incoming Response. Must be HttpResponse or RpcResponse.@FunctionalInterface public interface Client<I extends Request,O extends Response> extends Unwrappable
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.
UserClient| Modifier and Type | Method and Description |
|---|---|
default <T> T |
as(Class<T> type)
Unwraps this
Client into the object of the specified type. |
O |
execute(ClientRequestContext ctx,
I req)
|
O execute(ClientRequestContext ctx, I req) throws Exception
default <T> T as(Class<T> type)
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);
as in interface Unwrappabletype - the type of the object to returntype if found, or null if not found.Clients.unwrap(Object, Class),
ClientFactory.unwrap(Object, Class),
UnwrappableCopyright © 2020 LeanCloud. All rights reserved.