blob: c19302fe4d20c6294e0491b2bc08dfefe7f451cf [file] [log] [blame]
Mark Sleed788b2e2006-09-07 01:26:35 +00001#ifndef _THRIFT_SERVER_TSERVER_H_
2#define _THRIFT_SERVER_TSERVER_H_ 1
Mark Sleee8540632006-05-30 09:24:40 +00003
Marc Slemko16698852006-08-04 03:16:10 +00004#include <TProcessor.h>
Mark Sleed788b2e2006-09-07 01:26:35 +00005#include <transport/TServerTransport.h>
6#include <transport/TTransportFactory.h>
Marc Slemko3ea00332006-08-17 01:11:13 +00007#include <concurrency/Thread.h>
Marc Slemko16698852006-08-04 03:16:10 +00008
9#include <boost/shared_ptr.hpp>
Mark Sleee8540632006-05-30 09:24:40 +000010
Marc Slemko6f038a72006-08-03 18:58:09 +000011namespace facebook { namespace thrift { namespace server {
12
13using namespace facebook::thrift;
Mark Sleed788b2e2006-09-07 01:26:35 +000014using namespace facebook::thrift::transport;
Marc Slemko16698852006-08-04 03:16:10 +000015using namespace boost;
Marc Slemko6f038a72006-08-03 18:58:09 +000016
Mark Sleee8540632006-05-30 09:24:40 +000017class TServerOptions;
18
19/**
20 * Thrift server.
21 *
22 * @author Mark Slee <mcslee@facebook.com>
23 */
Marc Slemko3ea00332006-08-17 01:11:13 +000024class TServer : public concurrency::Runnable {
Marc Slemko16698852006-08-04 03:16:10 +000025public:
Mark Sleee8540632006-05-30 09:24:40 +000026 virtual ~TServer() {}
27 virtual void run() = 0;
Marc Slemko16698852006-08-04 03:16:10 +000028
29protected:
Mark Sleed788b2e2006-09-07 01:26:35 +000030 TServer(shared_ptr<TProcessor> processor,
31 shared_ptr<TServerTransport> serverTransport,
32 shared_ptr<TTransportFactory> transportFactory,
33 shared_ptr<TServerOptions> options) :
34 processor_(processor),
35 serverTransport_(serverTransport),
36 transportFactory_(transportFactory),
37 options_(options) {}
38
39 TServer(shared_ptr<TProcessor> processor,
40 shared_ptr<TServerOptions> options) :
Mark Slee8d7e1f62006-06-07 06:48:56 +000041 processor_(processor), options_(options) {}
Mark Sleed788b2e2006-09-07 01:26:35 +000042
Marc Slemko16698852006-08-04 03:16:10 +000043 shared_ptr<TProcessor> processor_;
Mark Sleed788b2e2006-09-07 01:26:35 +000044 shared_ptr<TServerTransport> serverTransport_;
45 shared_ptr<TTransportFactory> transportFactory_;
Marc Slemko16698852006-08-04 03:16:10 +000046 shared_ptr<TServerOptions> options_;
Mark Sleee8540632006-05-30 09:24:40 +000047};
Marc Slemko16698852006-08-04 03:16:10 +000048
Mark Sleee8540632006-05-30 09:24:40 +000049/**
50 * Class to encapsulate all generic server options.
51 */
52class TServerOptions {
Mark Sleed788b2e2006-09-07 01:26:35 +000053 public:
Mark Sleee8540632006-05-30 09:24:40 +000054 // TODO(mcslee): Fill in getters/setters here
Mark Sleed788b2e2006-09-07 01:26:35 +000055 protected:
Mark Sleee8540632006-05-30 09:24:40 +000056 // TODO(mcslee): Fill data members in here
57};
58
Marc Slemko6f038a72006-08-03 18:58:09 +000059}}} // facebook::thrift::server
60
Mark Sleed788b2e2006-09-07 01:26:35 +000061#endif // #ifndef _THRIFT_SERVER_TSERVER_H_