Mark Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 1 | // Copyright (c) 2006- Facebook |
| 2 | // Distributed under the Thrift Software License |
| 3 | // |
| 4 | // See accompanying file LICENSE or visit the Thrift site at: |
| 5 | // http://developers.facebook.com/thrift/ |
| 6 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 7 | #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ |
| 8 | #define _THRIFT_SERVER_TSIMPLESERVER_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 9 | |
| 10 | #include "server/TServer.h" |
| 11 | #include "transport/TServerTransport.h" |
| 12 | |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 13 | namespace facebook { namespace thrift { namespace server { |
| 14 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 15 | /** |
| 16 | * This is the most basic simple server. It is single-threaded and runs a |
| 17 | * continuous loop of accepting a single connection, processing requests on |
| 18 | * that connection until it closes, and then repeating. It is a good example |
| 19 | * of how to extend the TServer interface. |
| 20 | * |
| 21 | * @author Mark Slee <mcslee@facebook.com> |
| 22 | */ |
| 23 | class TSimpleServer : public TServer { |
| 24 | public: |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 25 | TSimpleServer(shared_ptr<TProcessor> processor, |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 26 | shared_ptr<TServerTransport> serverTransport, |
| 27 | shared_ptr<TTransportFactory> transportFactory, |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 28 | shared_ptr<TProtocolFactory> protocolFactory) : |
| 29 | TServer(processor, serverTransport, transportFactory, protocolFactory) {} |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 30 | |
| 31 | TSimpleServer(shared_ptr<TProcessor> processor, |
| 32 | shared_ptr<TServerTransport> serverTransport, |
| 33 | shared_ptr<TTransportFactory> inputTransportFactory, |
| 34 | shared_ptr<TTransportFactory> outputTransportFactory, |
| 35 | shared_ptr<TProtocolFactory> inputProtocolFactory, |
| 36 | shared_ptr<TProtocolFactory> outputProtocolFactory): |
| 37 | TServer(processor, serverTransport, |
| 38 | inputTransportFactory, outputTransportFactory, |
| 39 | inputProtocolFactory, outputProtocolFactory) {} |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 40 | |
| 41 | ~TSimpleServer() {} |
| 42 | |
Mark Slee | 794993d | 2006-09-20 01:56:10 +0000 | [diff] [blame] | 43 | void serve(); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 44 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 45 | }; |
| 46 | |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 47 | }}} // facebook::thrift::server |
| 48 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 49 | #endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ |