- 授权协议: 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();
}
});
}
硅谷增长黑客实战笔记
曲卉 / 机械工业出版社 / 2018-4-10 / 65.00元
增长黑客这个词源于硅谷,简单说,这是一群以数据驱动营销、以迭代验证策略,通过技术手段实现爆发式增长的新型人才。近年来,互联网公司意识到这一角色可以发挥四两拨千斤的作用,因此对该职位的需求也如井喷式增长。 本书作者曾在增长黑客之父肖恩•埃利斯麾下担任增长负责人,用亲身经历为你总结出增长黑客必备的套路、内力和兵法。本书不仅有逻辑清晰的理论体系、干货满满的实践心得,还有Pinterest、SoFi......一起来看看 《硅谷增长黑客实战笔记》 这本书的介绍吧!
