Interface THttpClient
- All Superinterfaces:
ClientBuilderParams
,Unwrappable
public interface THttpClient extends Unwrappable, ClientBuilderParams
A generic Thrift-over-HTTP client.
You will usually create a Thrift client object that implements a specific Thrift service interface
(e.g. HelloService.AsyncIface
):
HelloService.AsyncIface client = Clients.newClient(
"tbinary+http://127.0.0.1/hello", HelloService.AsyncIface.class);
client.hello("John Doe", ...);
However, if you want a generic Thrift client that works with any Thrift services, this client may be useful:
ThriftClient client = Clients.newClient("tbinary+http://127.0.0.1/", ThriftClient.class);
client.execute("/hello", HelloService.Iface.class, "hello", "John Doe");
client.execute("/foo", FooService.Iface.class, "foo", "arg1", "arg2", ...);
-
Method Summary
Modifier and Type Method Description RpcResponse
execute(String path, Class<?> serviceType, String method, Object... args)
Executes the specified Thrift call.RpcResponse
executeMultiplexed(String path, Class<?> serviceType, String serviceName, String method, Object... args)
Executes the specified multiplexed Thrift call.RpcClient
unwrap()
Unwraps this object and returns the object being decorated.Methods inherited from interface com.linecorp.armeria.client.ClientBuilderParams
absolutePathRef, clientType, endpointGroup, options, scheme, uri
-
Method Details
-
execute
Executes the specified Thrift call.- Parameters:
path
- the path of the Thrift serviceserviceType
- the Thrift service interfacemethod
- the method nameargs
- the arguments of the call
-
executeMultiplexed
RpcResponse executeMultiplexed(String path, Class<?> serviceType, String serviceName, String method, Object... args)Executes the specified multiplexed Thrift call.- Parameters:
path
- the path of the Thrift serviceserviceType
- the Thrift service interfaceserviceName
- the Thrift service namemethod
- the method nameargs
- the arguments of the call
-
unwrap
RpcClient unwrap()Description copied from interface:Unwrappable
Unwraps this object and returns the object being decorated. If thisUnwrappable
is the innermost object, this method returns itself. For example:class Foo implements Unwrappable {} class Bar<T extends Unwrappable> extends AbstractUnwrappable<T> { Bar(T delegate) { super(delegate); } } class Qux<T extends Unwrappable> extends AbstractUnwrappable<T> { Qux(T delegate) { super(delegate); } } Foo foo = new Foo(); assert foo.unwrap() == foo; Bar<Foo> bar = new Bar<>(foo); assert bar.unwrap() == foo; Qux<Bar<Foo>> qux = new Qux<>(bar); assert qux.unwrap() == bar; assert qux.unwrap().unwrap() == foo;
- Specified by:
unwrap
in interfaceUnwrappable
-