Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

irenical/thrifty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thrifty

Thrifty is a general-purpose implementation of a Thrift server, with boot and shutdown logic.

Usage

Thrifty uses jindy for configuration, so make sure you have a jindy binding on your classpath.
In your code (possibly in your main class), you can instantiate a thrift server through it's lifecycle interface.

TProcessor myProcessor = new MyThriftStub.Processor<MyThriftStub.Iface>(myThriftImplementation);
ThriftServerLifeCycle thrift = new ThriftServerLifeCycle(myProcessor, ConfigFactory.getConfig());
thrift.start();

Although a new thread will be created to run the server, for convenience the .start() method blocks until the server is ready to receive requests. Calling .stop() will prevent new requests from being accepted, then wait for the pending ones to finish and only then stop the server.

Thrifty will look for the following properties, using these defaults.

thrift.listenPort=1337 #Mandatory, no default value
thrift.selectorThreads=2
thrift.workerThreads=4
thrift.shutdownTimeoutMillis=10000
thrift.startupTimeoutSeconds=180
thrift.protocol=binary

Thrifty uses TNonblockingServerTransport and TThreadedSelectorServer