Skip to content

a little、 light and simple thrift client library, for java,android,etc..

Notifications You must be signed in to change notification settings

houkx/LibThriftClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

LibThriftClient

a little、 light and simple thrift client library, for java,android,etc..

Who need it

people use thrift protocol, a RCP selection.

  • want a litte interface jar,such as android use.
  • the server has many iterface methods,but you or your customer just need little some of these.
# How to use if you have a .thrift file like this: ```c struct Person{ 1:string name; 2:i32 age; } service HelloService{ String sayHi(1:Person aPerson)throws(1:HelloException ex); ... other methods } exception HelloException{ 1:i32 errorCode, 2:string errorDesc; } ... ```

you can write a Iterface and a JavaBean like this:

public interface MyService{// the name of this Iterface is random as you like
   // you could only have a single method,but the server has manay methods.
   // in this way,you can hide interface to your Customer
   String sayHi(Person p) throws HelloException;
   // the ParameterName of every parameter is same as it in the .thrift file
}
public class Person{
   public @Index(1) String name;
   public @Index(2) int age;
   ... optional Getters and Setter
}

Invoke example:

TProtocol iprot =....
MyService clientIface = ClientInterfaceFactory.getClientInterface(MyService.class,iprot);
Person liming = new Person();
liming.name="LiMing";
String response = clientIface.sayHi(liming);
System.out.println(response);

About

a little、 light and simple thrift client library, for java,android,etc..

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages