Skip to content

langwolf/netty-thrift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Netty-Thrift

Thrift on Netty

  • jdk1.8, netty4.1.20.Final, thrift0.9.3
  • based on nettythrift and nifty
  • add Multi-service mode

Example

Map<String, TBaseProcessor<?>> map = Maps.newHashMap();
map.put("test", new TCalculator.Processor<TCalculator.Iface>(new CalcIfaceImpl()));	
map.put("test2", new TCalculator.Processor<TCalculator.Iface>(new CalcIfaceImpl()));
TNettyThriftServer.Args nettyArg = new TNettyThriftServer.Args(8090);
nettyArg.setMaxReadBuffer(1024 * 100);
nettyArg.setMap(map);
final TServer nettyServer = new TNettyThriftServer(nettyArg);
  new Thread(()->{
	  nettyServer.serve();
	}).start();

OR

Map<String, TBaseProcessor<?>> map = Maps.newHashMap();
map.put("test", new TCalculator.Processor<TCalculator.Iface>(new CalcIfaceImpl()));	
map.put("test2", new TCalculator.Processor<TCalculator.Iface>(new CalcIfaceImpl()));
ThriftServerDef[] serverDefs = ThriftServerDef.newBuilder().listen(port)
  .withProcessors(map)
  .using(Executors.newCachedThreadPool())
  .builds();
final MultiServerBootstrap server = new MultiServerBootstrap(serverDefs, 8089, TimeUnit.SECONDS.toMillis(15));
server.start();	

Releases

No releases published

Packages

No packages published

Languages