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 */ 19 20 #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ 21 #define _THRIFT_SERVER_TSIMPLESERVER_H_ 1 22 23 #include <thrift/server/TServerFramework.h> 24 25 namespace apache { 26 namespace thrift { 27 namespace server { 28 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 32 * that connection until it closes, and then repeating. 33 */ 34 class TSimpleServer : public TServerFramework { 35 public: 36 TSimpleServer( 37 const std::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, 38 const std::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, 39 const std::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, 40 const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); 41 42 TSimpleServer( 43 const std::shared_ptr<apache::thrift::TProcessor>& processor, 44 const std::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, 45 const std::shared_ptr<apache::thrift::transport::TTransportFactory>& transportFactory, 46 const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& protocolFactory); 47 48 TSimpleServer( 49 const std::shared_ptr<apache::thrift::TProcessorFactory>& processorFactory, 50 const std::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, 51 const std::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, 52 const std::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, 53 const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, 54 const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); 55 56 TSimpleServer( 57 const std::shared_ptr<apache::thrift::TProcessor>& processor, 58 const std::shared_ptr<apache::thrift::transport::TServerTransport>& serverTransport, 59 const std::shared_ptr<apache::thrift::transport::TTransportFactory>& inputTransportFactory, 60 const std::shared_ptr<apache::thrift::transport::TTransportFactory>& outputTransportFactory, 61 const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& inputProtocolFactory, 62 const std::shared_ptr<apache::thrift::protocol::TProtocolFactory>& outputProtocolFactory); 63 64 ~TSimpleServer() override; 65 66 protected: 67 void onClientConnected(const std::shared_ptr<TConnectedClient>& pClient) override /* override */; 68 void onClientDisconnected(TConnectedClient* pClient) override /* override */; 69 70 private: 71 void setConcurrentClientLimit(int64_t newLimit) override; // hide 72 }; 73 } 74 } 75 } // apache::thrift::server 76 77 #endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_ 78