Re-sync with internal repository
[hiphop-php.git] / third-party / thrift / src / thrift / compiler / test / fixtures / basic / gen-cpp2 / DbMixedStackArgumentsAsyncClient.h
blobde1e70be0cbdeca44f0975cb95fa7605728811fd
1 /**
2 * Autogenerated by Thrift for src/module.thrift
4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 * @generated @nocommit
6 */
7 #pragma once
9 #include <thrift/lib/cpp2/gen/client_h.h>
11 #include "thrift/compiler/test/fixtures/basic/gen-cpp2/module_types.h"
12 #include "thrift/annotation/gen-cpp2/hack_types.h"
14 namespace apache { namespace thrift {
15 class Cpp2RequestContext;
16 namespace detail { namespace ac { struct ClientRequestContext; }}
17 namespace transport { class THeader; }
20 namespace test { namespace fixtures { namespace basic {
21 class DbMixedStackArguments;
22 }}} // test::fixtures::basic
23 namespace apache::thrift {
25 template <>
26 class Client<::test::fixtures::basic::DbMixedStackArguments> : public apache::thrift::GeneratedAsyncClient {
27 public:
28 using apache::thrift::GeneratedAsyncClient::GeneratedAsyncClient;
30 char const* getServiceName() const noexcept override {
31 return "DbMixedStackArguments";
34 static const char* __fbthrift_thrift_uri() {
35 return "test.dev/fixtures/basic/DbMixedStackArguments";
39 virtual void getDataByKey0(std::unique_ptr<apache::thrift::RequestCallback> callback, const ::std::string& p_key);
40 virtual void getDataByKey0(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, const ::std::string& p_key);
41 protected:
42 void getDataByKey0Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const ::std::string& p_key, bool stealRpcOptions = false);
43 public:
45 virtual void sync_getDataByKey0(::std::string& _return, const ::std::string& p_key);
46 virtual void sync_getDataByKey0(apache::thrift::RpcOptions& rpcOptions, ::std::string& _return, const ::std::string& p_key);
48 virtual folly::Future<::std::string> future_getDataByKey0(const ::std::string& p_key);
49 virtual folly::SemiFuture<::std::string> semifuture_getDataByKey0(const ::std::string& p_key);
50 virtual folly::Future<::std::string> future_getDataByKey0(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
51 virtual folly::SemiFuture<::std::string> semifuture_getDataByKey0(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
52 virtual folly::Future<std::pair<::std::string, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_getDataByKey0(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
53 virtual folly::SemiFuture<std::pair<::std::string, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_getDataByKey0(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
55 #if FOLLY_HAS_COROUTINES
56 #if __clang__
57 template <int = 0>
58 folly::coro::Task<::std::string> co_getDataByKey0(const ::std::string& p_key) {
59 return co_getDataByKey0<false>(nullptr, p_key);
61 template <int = 0>
62 folly::coro::Task<::std::string> co_getDataByKey0(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key) {
63 return co_getDataByKey0<true>(&rpcOptions, p_key);
65 #else
66 folly::coro::Task<::std::string> co_getDataByKey0(const ::std::string& p_key) {
67 co_return co_await folly::coro::detachOnCancel(semifuture_getDataByKey0(p_key));
69 folly::coro::Task<::std::string> co_getDataByKey0(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key) {
70 co_return co_await folly::coro::detachOnCancel(semifuture_getDataByKey0(rpcOptions, p_key));
72 #endif
73 private:
74 template <bool hasRpcOptions>
75 folly::coro::Task<::std::string> co_getDataByKey0(apache::thrift::RpcOptions* rpcOptions, const ::std::string& p_key) {
76 const folly::CancellationToken& cancelToken =
77 co_await folly::coro::co_current_cancellation_token;
78 const bool cancellable = cancelToken.canBeCancelled();
79 apache::thrift::ClientReceiveState returnState;
80 apache::thrift::ClientCoroCallback<false> callback(&returnState, co_await folly::coro::co_current_executor);
81 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
82 auto [ctx, header] = getDataByKey0Ctx(rpcOptions);
83 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
84 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
85 static apache::thrift::RpcOptions defaultRpcOptions;
86 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
87 if constexpr (hasRpcOptions) {
88 getDataByKey0Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_key);
89 } else {
90 getDataByKey0Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_key);
92 if (cancellable) {
93 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
94 co_await callback.co_waitUntilDone();
95 } else {
96 co_await callback.co_waitUntilDone();
98 if (returnState.isException()) {
99 co_yield folly::coro::co_error(std::move(returnState.exception()));
101 returnState.resetProtocolId(protocolId);
102 returnState.resetCtx(std::move(ctx));
103 SCOPE_EXIT {
104 if (hasRpcOptions && returnState.header()) {
105 auto* rheader = returnState.header();
106 if (!rheader->getHeaders().empty()) {
107 rpcOptions->setReadHeaders(rheader->releaseHeaders());
109 rpcOptions->setRoutingData(rheader->releaseRoutingData());
112 ::std::string _return;
113 if (auto ew = recv_wrapped_getDataByKey0(_return, returnState)) {
114 co_yield folly::coro::co_error(std::move(ew));
116 co_return _return;
118 public:
119 #endif // FOLLY_HAS_COROUTINES
121 virtual void getDataByKey0(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, const ::std::string& p_key);
124 static folly::exception_wrapper recv_wrapped_getDataByKey0(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
125 static void recv_getDataByKey0(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
126 // Mock friendly virtual instance method
127 virtual void recv_instance_getDataByKey0(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
128 virtual folly::exception_wrapper recv_instance_wrapped_getDataByKey0(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
129 private:
130 template <typename Protocol_, typename RpcOptions>
131 void getDataByKey0T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const ::std::string& p_key);
132 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> getDataByKey0Ctx(apache::thrift::RpcOptions* rpcOptions);
133 public:
134 virtual void getDataByKey1(std::unique_ptr<apache::thrift::RequestCallback> callback, const ::std::string& p_key);
135 virtual void getDataByKey1(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, const ::std::string& p_key);
136 protected:
137 void getDataByKey1Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const ::std::string& p_key, bool stealRpcOptions = false);
138 public:
140 virtual void sync_getDataByKey1(::std::string& _return, const ::std::string& p_key);
141 virtual void sync_getDataByKey1(apache::thrift::RpcOptions& rpcOptions, ::std::string& _return, const ::std::string& p_key);
143 virtual folly::Future<::std::string> future_getDataByKey1(const ::std::string& p_key);
144 virtual folly::SemiFuture<::std::string> semifuture_getDataByKey1(const ::std::string& p_key);
145 virtual folly::Future<::std::string> future_getDataByKey1(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
146 virtual folly::SemiFuture<::std::string> semifuture_getDataByKey1(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
147 virtual folly::Future<std::pair<::std::string, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_getDataByKey1(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
148 virtual folly::SemiFuture<std::pair<::std::string, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_getDataByKey1(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key);
150 #if FOLLY_HAS_COROUTINES
151 #if __clang__
152 template <int = 0>
153 folly::coro::Task<::std::string> co_getDataByKey1(const ::std::string& p_key) {
154 return co_getDataByKey1<false>(nullptr, p_key);
156 template <int = 0>
157 folly::coro::Task<::std::string> co_getDataByKey1(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key) {
158 return co_getDataByKey1<true>(&rpcOptions, p_key);
160 #else
161 folly::coro::Task<::std::string> co_getDataByKey1(const ::std::string& p_key) {
162 co_return co_await folly::coro::detachOnCancel(semifuture_getDataByKey1(p_key));
164 folly::coro::Task<::std::string> co_getDataByKey1(apache::thrift::RpcOptions& rpcOptions, const ::std::string& p_key) {
165 co_return co_await folly::coro::detachOnCancel(semifuture_getDataByKey1(rpcOptions, p_key));
167 #endif
168 private:
169 template <bool hasRpcOptions>
170 folly::coro::Task<::std::string> co_getDataByKey1(apache::thrift::RpcOptions* rpcOptions, const ::std::string& p_key) {
171 const folly::CancellationToken& cancelToken =
172 co_await folly::coro::co_current_cancellation_token;
173 const bool cancellable = cancelToken.canBeCancelled();
174 apache::thrift::ClientReceiveState returnState;
175 apache::thrift::ClientCoroCallback<false> callback(&returnState, co_await folly::coro::co_current_executor);
176 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId();
177 auto [ctx, header] = getDataByKey1Ctx(rpcOptions);
178 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>;
179 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr;
180 static apache::thrift::RpcOptions defaultRpcOptions;
181 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback);
182 if constexpr (hasRpcOptions) {
183 getDataByKey1Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_key);
184 } else {
185 getDataByKey1Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_key);
187 if (cancellable) {
188 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); });
189 co_await callback.co_waitUntilDone();
190 } else {
191 co_await callback.co_waitUntilDone();
193 if (returnState.isException()) {
194 co_yield folly::coro::co_error(std::move(returnState.exception()));
196 returnState.resetProtocolId(protocolId);
197 returnState.resetCtx(std::move(ctx));
198 SCOPE_EXIT {
199 if (hasRpcOptions && returnState.header()) {
200 auto* rheader = returnState.header();
201 if (!rheader->getHeaders().empty()) {
202 rpcOptions->setReadHeaders(rheader->releaseHeaders());
204 rpcOptions->setRoutingData(rheader->releaseRoutingData());
207 ::std::string _return;
208 if (auto ew = recv_wrapped_getDataByKey1(_return, returnState)) {
209 co_yield folly::coro::co_error(std::move(ew));
211 co_return _return;
213 public:
214 #endif // FOLLY_HAS_COROUTINES
216 virtual void getDataByKey1(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, const ::std::string& p_key);
219 static folly::exception_wrapper recv_wrapped_getDataByKey1(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
220 static void recv_getDataByKey1(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
221 // Mock friendly virtual instance method
222 virtual void recv_instance_getDataByKey1(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
223 virtual folly::exception_wrapper recv_instance_wrapped_getDataByKey1(::std::string& _return, ::apache::thrift::ClientReceiveState& state);
224 private:
225 template <typename Protocol_, typename RpcOptions>
226 void getDataByKey1T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const ::std::string& p_key);
227 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> getDataByKey1Ctx(apache::thrift::RpcOptions* rpcOptions);
228 public:
231 } // namespace apache::thrift
233 namespace test { namespace fixtures { namespace basic {
234 using DbMixedStackArgumentsAsyncClient [[deprecated("Use apache::thrift::Client<DbMixedStackArguments> instead")]] = ::apache::thrift::Client<DbMixedStackArguments>;
235 }}} // test::fixtures::basic