File indexing completed on 2026-04-17 08:35:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef _THRIFT_TEVHTTP_CLIENT_CHANNEL_H_
0021 #define _THRIFT_TEVHTTP_CLIENT_CHANNEL_H_ 1
0022
0023 #include <queue>
0024 #include <string>
0025 #include <utility>
0026 #include <memory>
0027 #include <thrift/async/TAsyncChannel.h>
0028
0029 struct event_base;
0030 struct evdns_base;
0031 struct evhttp_connection;
0032 struct evhttp_request;
0033
0034 namespace apache {
0035 namespace thrift {
0036 namespace transport {
0037 class TMemoryBuffer;
0038 }
0039 }
0040 }
0041
0042 namespace apache {
0043 namespace thrift {
0044 namespace async {
0045
0046 class TEvhttpClientChannel : public TAsyncChannel {
0047 public:
0048 using TAsyncChannel::VoidCallback;
0049
0050 TEvhttpClientChannel(const std::string& host,
0051 const std::string& path,
0052 const char* address,
0053 int port,
0054 struct event_base* eb,
0055 struct evdns_base *dnsbase = nullptr);
0056 ~TEvhttpClientChannel() override;
0057
0058 void sendAndRecvMessage(const VoidCallback& cob,
0059 apache::thrift::transport::TMemoryBuffer* sendBuf,
0060 apache::thrift::transport::TMemoryBuffer* recvBuf) override;
0061
0062 void sendMessage(const VoidCallback& cob,
0063 apache::thrift::transport::TMemoryBuffer* message) override;
0064 void recvMessage(const VoidCallback& cob,
0065 apache::thrift::transport::TMemoryBuffer* message) override;
0066
0067 void finish(struct evhttp_request* req);
0068
0069
0070 bool good() const override { return true; }
0071 bool error() const override { return false; }
0072 bool timedOut() const override { return false; }
0073
0074 private:
0075 static void response(struct evhttp_request* req, void* arg);
0076
0077 std::string host_;
0078 std::string path_;
0079 typedef std::pair<VoidCallback, apache::thrift::transport::TMemoryBuffer*> Completion;
0080 typedef std::queue<Completion> CompletionQueue;
0081 CompletionQueue completionQueue_;
0082 struct evhttp_connection* conn_;
0083 };
0084 }
0085 }
0086 }
0087
0088 #endif