blob: 391fbec8c9c850c0108de9cd0b74b66ff45a5ced [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
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 Slee9f0c6512007-02-28 23:58:26 +000019
Mark Sleed788b2e2006-09-07 01:26:35 +000020#ifndef _THRIFT_SERVER_TSIMPLESERVER_H_
21#define _THRIFT_SERVER_TSIMPLESERVER_H_ 1
Mark Sleee8540632006-05-30 09:24:40 +000022
Jim King21b68522015-04-26 18:30:26 -040023#include <thrift/server/TServerFramework.h>
Mark Sleee8540632006-05-30 09:24:40 +000024
Konrad Grochowski16a23a62014-11-13 15:33:38 +010025namespace apache {
26namespace thrift {
27namespace server {
Marc Slemko6f038a72006-08-03 18:58:09 +000028
Mark Sleee8540632006-05-30 09:24:40 +000029/**
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 King21b68522015-04-26 18:30:26 -040032 * that connection until it closes, and then repeating.
Mark Sleee8540632006-05-30 09:24:40 +000033 */
Jim King21b68522015-04-26 18:30:26 -040034class TSimpleServer : public TServerFramework {
Konrad Grochowski16a23a62014-11-13 15:33:38 +010035public:
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020036 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 Duxbury7a9fb812011-09-01 18:31:53 +000041
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020042 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 Agarwal9abb0d62007-01-24 22:53:54 +000047
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020048 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 Duxbury7a9fb812011-09-01 18:31:53 +000055
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020056 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 Sleeb4d3e7b2007-11-28 01:51:43 +000063
Jim King21b68522015-04-26 18:30:26 -040064 virtual ~TSimpleServer();
Mark Slee6e3f6372007-03-01 22:05:46 +000065
Konrad Grochowski16a23a62014-11-13 15:33:38 +010066protected:
Jim King21b68522015-04-26 18:30:26 -040067 virtual void onClientConnected(const boost::shared_ptr<TConnectedClient>& pClient) /* override */;
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020068 virtual void onClientDisconnected(TConnectedClient* pClient) /* override */;
Jim King79c99112015-04-30 07:10:08 -040069
70private:
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020071 void setConcurrentClientLimit(int64_t newLimit); // hide
Mark Sleee8540632006-05-30 09:24:40 +000072};
Konrad Grochowski16a23a62014-11-13 15:33:38 +010073}
74}
75} // apache::thrift::server
Marc Slemko6f038a72006-08-03 18:58:09 +000076
Mark Sleed788b2e2006-09-07 01:26:35 +000077#endif // #ifndef _THRIFT_SERVER_TSIMPLESERVER_H_