]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/cpp/src/thrift/server/TConnectedClient.h
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / cpp / src / thrift / server / TConnectedClient.h
CommitLineData
f67539c2
TL
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_TCONNECTEDCLIENT_H_
21#define _THRIFT_SERVER_TCONNECTEDCLIENT_H_ 1
22
23#include <memory>
24#include <thrift/TProcessor.h>
25#include <thrift/protocol/TProtocol.h>
26#include <thrift/server/TServer.h>
27#include <thrift/transport/TTransport.h>
28
29namespace apache {
30namespace thrift {
31namespace server {
32
33/**
34 * This represents a client connected to a TServer. The
35 * processing loop for a client must provide some required
36 * functionality common to all implementations so it is
37 * encapsulated here.
38 */
39
40class TConnectedClient : public apache::thrift::concurrency::Runnable {
41public:
42 /**
43 * Constructor.
44 *
45 * @param[in] processor the TProcessor
46 * @param[in] inputProtocol the input TProtocol
47 * @param[in] outputProtocol the output TProtocol
48 * @param[in] eventHandler the server event handler
49 * @param[in] client the TTransport representing the client
50 */
51 TConnectedClient(
52 const std::shared_ptr<apache::thrift::TProcessor>& processor,
53 const std::shared_ptr<apache::thrift::protocol::TProtocol>& inputProtocol,
54 const std::shared_ptr<apache::thrift::protocol::TProtocol>& outputProtocol,
55 const std::shared_ptr<apache::thrift::server::TServerEventHandler>& eventHandler,
56 const std::shared_ptr<apache::thrift::transport::TTransport>& client);
57
58 /**
59 * Destructor.
60 */
61 ~TConnectedClient() override;
62
63 /**
64 * Drive the client until it is done.
65 * The client processing loop is:
66 *
67 * [optional] call eventHandler->createContext once
68 * [optional] call eventHandler->processContext per request
69 * call processor->process per request
70 * handle expected transport exceptions:
71 * END_OF_FILE means the client is gone
72 * INTERRUPTED means the client was interrupted
73 * by TServerTransport::interruptChildren()
74 * handle unexpected transport exceptions by logging
75 * handle standard exceptions by logging
76 * handle unexpected exceptions by logging
77 * cleanup()
78 */
79 void run() override /* override */;
80
81protected:
82 /**
83 * Cleanup after a client. This happens if the client disconnects,
84 * or if the server is stopped, or if an exception occurs.
85 *
86 * The cleanup processing is:
87 * [optional] call eventHandler->deleteContext once
88 * close the inputProtocol's TTransport
89 * close the outputProtocol's TTransport
90 * close the client
91 */
92 virtual void cleanup();
93
94private:
95 std::shared_ptr<apache::thrift::TProcessor> processor_;
96 std::shared_ptr<apache::thrift::protocol::TProtocol> inputProtocol_;
97 std::shared_ptr<apache::thrift::protocol::TProtocol> outputProtocol_;
98 std::shared_ptr<apache::thrift::server::TServerEventHandler> eventHandler_;
99 std::shared_ptr<apache::thrift::transport::TTransport> client_;
100
101 /**
102 * Context acquired from the eventHandler_ if one exists.
103 */
104 void* opaqueContext_;
105};
106}
107}
108}
109
110#endif // #ifndef _THRIFT_SERVER_TCONNECTEDCLIENT_H_