David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Mark Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 19 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 20 | #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ |
| 21 | #define _THRIFT_SERVER_TSIMPLESERVER_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 22 | |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 23 | #include <thrift/server/TServerFramework.h> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 24 | |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 25 | namespace apache { |
| 26 | namespace thrift { |
| 27 | namespace server { |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 28 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 29 | /** |
| 30 | * This is the most basic simple server. It is single-threaded and runs a |
| 31 | * continuous loop of accepting a single connection, processing requests on |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 32 | * that connection until it closes, and then repeating. |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 33 | */ |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 34 | class TSimpleServer : public TServerFramework { |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 35 | public: |
Konrad Grochowski | 1f6e380 | 2015-05-18 18:10:06 +0200 | [diff] [blame] | 36 | TSimpleServer( |
| 37 | const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, |
| 38 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 39 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, |
| 40 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame] | 41 | |
Konrad Grochowski | 1f6e380 | 2015-05-18 18:10:06 +0200 | [diff] [blame] | 42 | TSimpleServer( |
| 43 | const boost::shared_ptr<apache::thrift::TProcessor>& processor, |
| 44 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 45 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, |
| 46 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 47 | |
Konrad Grochowski | 1f6e380 | 2015-05-18 18:10:06 +0200 | [diff] [blame] | 48 | TSimpleServer( |
| 49 | const boost::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, |
| 50 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 51 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, |
| 52 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, |
| 53 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, |
| 54 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame] | 55 | |
Konrad Grochowski | 1f6e380 | 2015-05-18 18:10:06 +0200 | [diff] [blame] | 56 | TSimpleServer( |
| 57 | const boost::shared_ptr<apache::thrift::TProcessor>& processor, |
| 58 | const boost::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, |
| 59 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, |
| 60 | const boost::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, |
| 61 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, |
| 62 | const boost::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 63 | |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 64 | virtual ~TSimpleServer(); |
Mark Slee | 6e3f637 | 2007-03-01 22:05:46 +0000 | [diff] [blame] | 65 | |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 66 | protected: |
Jim King | 21b6852 | 2015-04-26 18:30:26 -0400 | [diff] [blame] | 67 | virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */; |
Konrad Grochowski | 1f6e380 | 2015-05-18 18:10:06 +0200 | [diff] [blame] | 68 | virtual void onClientDisconnected(TConnectedClient* pClient) /* override */; |
Jim King | 79c9911 | 2015-04-30 07:10:08 -0400 | [diff] [blame] | 69 | |
| 70 | private: |
Konrad Grochowski | 1f6e380 | 2015-05-18 18:10:06 +0200 | [diff] [blame] | 71 | void setConcurrentClientLimit(int64_t newLimit); // hide |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 72 | }; |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 73 | } |
| 74 | } |
| 75 | } // apache::thrift::server |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 76 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 77 | #endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ |