- 授权协议: Apache
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/facebook/nifty
- 软件文档: https://github.com/facebook/nifty
软件介绍
Nifty是facebook公司开源的,基于netty的thrift服务端和客户端实现。
然后使用此包就可以快速发布出基于netty的高效的服务端和客户端代码。
示例:
public void startServer() {
// Create the handler
MyService.Iface serviceInterface = new MyServiceHandler();
// Create the processor
TProcessor processor = new MyService.Processor<>(serviceInterface);
// Build the server definition
ThriftServerDef serverDef = new ThriftServerDefBuilder().withProcessor(processor)
.build();
// Create the server transport
final NettyServerTransport server = new NettyServerTransport(serverDef,
new NettyConfigBuilder(),
new DefaultChannelGroup(),
new HashedWheelTimer());
// Create netty boss and executor thread pools
ExecutorService bossExecutor = Executors.newCachedThreadPool();
ExecutorService workerExecutor = Executors.newCachedThreadPool();
// Start the server
server.start(bossExecutor, workerExecutor);
// Arrange to stop the server at shutdown
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
server.stop();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
});
}
Or the same thing using guice:
public void startGuiceServer() {
final NiftyBootstrap bootstrap = Guice.createInjector(
Stage.PRODUCTION,
new NiftyModule() {
@Override
protected void configureNifty() {
// Create the handler
MyService.Iface serviceInterface = new MyServiceHandler();
// Create the processor
TProcessor processor = new MyService.Processor<>(serviceInterface);
// Build the server definition
ThriftServerDef serverDef = new ThriftServerDefBuilder().withProcessor(processor)
.build();
// Bind the definition
bind().toInstance(serverDef);
}
}).getInstance(NiftyBootstrap.class);
// Start the server
bootstrap.start();
// Arrange to stop the server at shutdown
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
bootstrap.stop();
}
});
}
Head First Python(中文版)
巴里(Barry.P.) / 林琪 等 / 中国电力出版社 / 2012-3-1 / 68.00元
你想过可以通过一本书就学会Python吗?《Head First Python(中文版)》超越枯燥的语法和甩法手册,通过一种独特的方法教你学习这种语言。你会迅速掌握Python的基础知识,然后转向持久存储、异常处理、Web开发、SQLite、数据加工和lGoogle App Engine。你还将学习如何为Android编写移动应用,这都要归功于Python为你赋予的强大能力。本书会提供充分并且完备......一起来看看 《Head First Python(中文版)》 这本书的介绍吧!
RGB转16进制工具
RGB HEX 互转工具
Markdown 在线编辑器
Markdown 在线编辑器
