lion-socket provides a rpc solution for using thrift.
The server-side is built upon netty which supports asynchronous and non-blocking io functionality
Use an IDL thrift file and generate a java source file.
a simple sample:
namespace java com.lioncorp.service.thrift.iface
service TCalculator {
string ping()
}
Develop a server-side service implementation. Below is an example based on the IDL generated java code. set the service name as "Ttest"
@LionImpl(ApiName = "Ttest",
ApiIfaceClazz = TCalculator.Iface.class,
ApiProcessorClazz = TCalculator.Processor.class)
public class CalcIfaceImpl implements TCalculator.Iface {
@Override
public String ping() throws TException {
System.out.println("...");
return "PONG";
}
}
Then start the server on port 9000.
LionServer lionServer = LionServer.newBuilder().listen(9000)
.register(new CalcIfaceImpl()).build();
lionServer.start();