Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 1 | #ifndef _THRIFT_SERVER_TSERVER_H_ |
| 2 | #define _THRIFT_SERVER_TSERVER_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 3 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 4 | #include <TProcessor.h> |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 5 | #include <transport/TServerTransport.h> |
| 6 | #include <transport/TTransportFactory.h> |
Marc Slemko | 3ea0033 | 2006-08-17 01:11:13 +0000 | [diff] [blame] | 7 | #include <concurrency/Thread.h> |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 8 | |
| 9 | #include <boost/shared_ptr.hpp> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 10 | |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 11 | namespace facebook { namespace thrift { namespace server { |
| 12 | |
| 13 | using namespace facebook::thrift; |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 14 | using namespace facebook::thrift::transport; |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 15 | using namespace boost; |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 16 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 17 | class TServerOptions; |
| 18 | |
| 19 | /** |
| 20 | * Thrift server. |
| 21 | * |
| 22 | * @author Mark Slee <mcslee@facebook.com> |
| 23 | */ |
Marc Slemko | 3ea0033 | 2006-08-17 01:11:13 +0000 | [diff] [blame] | 24 | class TServer : public concurrency::Runnable { |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 25 | public: |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 26 | virtual ~TServer() {} |
| 27 | virtual void run() = 0; |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 28 | |
| 29 | protected: |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 30 | 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 Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 41 | processor_(processor), options_(options) {} |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 42 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 43 | shared_ptr<TProcessor> processor_; |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 44 | shared_ptr<TServerTransport> serverTransport_; |
| 45 | shared_ptr<TTransportFactory> transportFactory_; |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 46 | shared_ptr<TServerOptions> options_; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 47 | }; |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 48 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 49 | /** |
| 50 | * Class to encapsulate all generic server options. |
| 51 | */ |
| 52 | class TServerOptions { |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 53 | public: |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 54 | // TODO(mcslee): Fill in getters/setters here |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 55 | protected: |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 56 | // TODO(mcslee): Fill data members in here |
| 57 | }; |
| 58 | |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 59 | }}} // facebook::thrift::server |
| 60 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 61 | #endif // #ifndef _THRIFT_SERVER_TSERVER_H_ |