|
|
|||
File indexing completed on 2026-04-17 08:35:02
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one 0003 * or more contributor license agreements. See the NOTICE file 0004 * distributed with this work for additional information 0005 * regarding copyright ownership. The ASF licenses this file 0006 * to you under the Apache License, Version 2.0 (the 0007 * "License"); you may not use this file except in compliance 0008 * with the License. You may obtain a copy of the License at 0009 * 0010 * http://www.apache.org/licenses/LICENSE-2.0 0011 * 0012 * Unless required by applicable law or agreed to in writing, 0013 * software distributed under the License is distributed on an 0014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 0015 * KIND, either express or implied. See the License for the 0016 * specific language governing permissions and limitations 0017 * under the License. 0018 */ 0019 0020 #ifndef _THRIFT_SERVER_TCONNECTEDCLIENT_H_ 0021 #define _THRIFT_SERVER_TCONNECTEDCLIENT_H_ 1 0022 0023 #include <memory> 0024 #include <thrift/TProcessor.h> 0025 #include <thrift/protocol/TProtocol.h> 0026 #include <thrift/server/TServer.h> 0027 #include <thrift/transport/TTransport.h> 0028 0029 namespace apache { 0030 namespace thrift { 0031 namespace server { 0032 0033 /** 0034 * This represents a client connected to a TServer. The 0035 * processing loop for a client must provide some required 0036 * functionality common to all implementations so it is 0037 * encapsulated here. 0038 */ 0039 0040 class TConnectedClient : public apache::thrift::concurrency::Runnable { 0041 public: 0042 /** 0043 * Constructor. 0044 * 0045 * @param[in] processor the TProcessor 0046 * @param[in] inputProtocol the input TProtocol 0047 * @param[in] outputProtocol the output TProtocol 0048 * @param[in] eventHandler the server event handler 0049 * @param[in] client the TTransport representing the client 0050 */ 0051 TConnectedClient( 0052 const std::shared_ptr<apache::thrift::TProcessor>& processor, 0053 const std::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol, 0054 const std::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol, 0055 const std::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler, 0056 const std::shared_ptr<apache::thrift::transport::TTransport>& client); 0057 0058 /** 0059 * Destructor. 0060 */ 0061 ~TConnectedClient() override; 0062 0063 /** 0064 * Drive the client until it is done. 0065 * The client processing loop is: 0066 * 0067 * [optional] call eventHandler->createContext once 0068 * [optional] call eventHandler->processContext per request 0069 * call processor->process per request 0070 * handle expected transport exceptions: 0071 * END_OF_FILE means the client is gone 0072 * INTERRUPTED means the client was interrupted 0073 * by TServerTransport::interruptChildren() 0074 * handle unexpected transport exceptions by logging 0075 * handle standard exceptions by logging 0076 * handle unexpected exceptions by logging 0077 * cleanup() 0078 */ 0079 void run() override /* override */; 0080 0081 protected: 0082 /** 0083 * Cleanup after a client. This happens if the client disconnects, 0084 * or if the server is stopped, or if an exception occurs. 0085 * 0086 * The cleanup processing is: 0087 * [optional] call eventHandler->deleteContext once 0088 * close the inputProtocol's TTransport 0089 * close the outputProtocol's TTransport 0090 * close the client 0091 */ 0092 virtual void cleanup(); 0093 0094 private: 0095 std::shared_ptr<apache::thrift::TProcessor> processor_; 0096 std::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_; 0097 std::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_; 0098 std::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_; 0099 std::shared_ptr<apache::thrift::transport::TTransport> client_; 0100 0101 /** 0102 * Context acquired from the eventHandler_ if one exists. 0103 */ 0104 void* opaqueContext_; 0105 }; 0106 } 0107 } 0108 } 0109 0110 #endif // #ifndef _THRIFT_SERVER_TCONNECTEDCLIENT_H_
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|