1 /** 2 * Autogenerated by Thrift for src/module.thrift 3 * 4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 * @generated @nocommit 6 */ 7 #pragma once 8 9 #include <thrift/lib/cpp2/gen/client_h.h> 10 11 #include "thrift/compiler/test/fixtures/fatal/gen-cpp2/module_types.h" 12 #include "thrift/compiler/test/fixtures/fatal/gen-cpp2/reflection_dep_B_types.h" 13 #include "thrift/compiler/test/fixtures/fatal/gen-cpp2/reflection_dep_C_types.h" 14 #include "thrift/test/fatal_custom_types.h" 15 16 namespace apache { namespace thrift { 17 class Cpp2RequestContext; 18 namespace detail { namespace ac { struct ClientRequestContext; }} 19 namespace transport { class THeader; } 20 }} 21 22 namespace test_cpp2 { namespace cpp_reflection { 23 24 class service1AsyncClient : public apache::thrift::GeneratedAsyncClient { 25 public: 26 using apache::thrift::GeneratedAsyncClient::GeneratedAsyncClient; 27 getServiceName()28 char const* getServiceName() const noexcept override { 29 return "service1"; 30 } 31 32 33 virtual void method1(std::unique_ptr<apache::thrift::RequestCallback> callback); 34 virtual void method1(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback); 35 protected: 36 void method1Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); 37 public: 38 39 virtual void sync_method1(); 40 virtual void sync_method1(apache::thrift::RpcOptions& rpcOptions); 41 42 virtual folly::Future<folly::Unit> future_method1(); 43 virtual folly::SemiFuture<folly::Unit> semifuture_method1(); 44 virtual folly::Future<folly::Unit> future_method1(apache::thrift::RpcOptions& rpcOptions); 45 virtual folly::SemiFuture<folly::Unit> semifuture_method1(apache::thrift::RpcOptions& rpcOptions); 46 virtual folly::Future<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_method1(apache::thrift::RpcOptions& rpcOptions); 47 virtual folly::SemiFuture<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_method1(apache::thrift::RpcOptions& rpcOptions); 48 49 #if FOLLY_HAS_COROUTINES 50 template <int = 0> co_method1()51 folly::coro::Task<void> co_method1() { 52 return co_method1<false>(nullptr); 53 } 54 template <int = 0> co_method1(apache::thrift::RpcOptions & rpcOptions)55 folly::coro::Task<void> co_method1(apache::thrift::RpcOptions& rpcOptions) { 56 return co_method1<true>(&rpcOptions); 57 } 58 private: 59 template <bool hasRpcOptions> co_method1(apache::thrift::RpcOptions * rpcOptions)60 folly::coro::Task<void> co_method1(apache::thrift::RpcOptions* rpcOptions) { 61 const folly::CancellationToken& cancelToken = 62 co_await folly::coro::co_current_cancellation_token; 63 const bool cancellable = cancelToken.canBeCancelled(); 64 apache::thrift::ClientReceiveState returnState; 65 apache::thrift::ClientSyncCallback<false> callback(&returnState); 66 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); 67 auto [ctx, header] = method1Ctx(rpcOptions); 68 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>; 69 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; 70 static apache::thrift::RpcOptions defaultRpcOptions; 71 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); 72 if constexpr (hasRpcOptions) { 73 method1Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); 74 } else { 75 method1Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); 76 } 77 if (cancellable) { 78 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); 79 co_await callback.co_waitUntilDone(); 80 } else { 81 co_await callback.co_waitUntilDone(); 82 } 83 if (returnState.isException()) { 84 co_yield folly::coro::co_error(std::move(returnState.exception())); 85 } 86 returnState.resetProtocolId(protocolId); 87 returnState.resetCtx(std::move(ctx)); 88 SCOPE_EXIT { 89 if (hasRpcOptions && returnState.header()) { 90 auto* rheader = returnState.header(); 91 if (!rheader->getHeaders().empty()) { 92 rpcOptions->setReadHeaders(rheader->releaseHeaders()); 93 } 94 rpcOptions->setRoutingData(rheader->releaseRoutingData()); 95 } 96 }; 97 if (auto ew = recv_wrapped_method1(returnState)) { 98 co_yield folly::coro::co_error(std::move(ew)); 99 } 100 } 101 public: 102 #endif // FOLLY_HAS_COROUTINES 103 104 virtual void method1(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback); 105 106 107 static folly::exception_wrapper recv_wrapped_method1(::apache::thrift::ClientReceiveState& state); 108 static void recv_method1(::apache::thrift::ClientReceiveState& state); 109 // Mock friendly virtual instance method 110 virtual void recv_instance_method1(::apache::thrift::ClientReceiveState& state); 111 virtual folly::exception_wrapper recv_instance_wrapped_method1(::apache::thrift::ClientReceiveState& state); 112 private: 113 template <typename Protocol_, typename RpcOptions> 114 void method1T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); 115 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> method1Ctx(apache::thrift::RpcOptions* rpcOptions); 116 public: 117 virtual void method2(std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 118 virtual void method2(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 119 protected: 120 void method2Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z, bool stealRpcOptions = false); 121 public: 122 123 virtual void sync_method2(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 124 virtual void sync_method2(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 125 126 virtual folly::Future<folly::Unit> future_method2(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 127 virtual folly::SemiFuture<folly::Unit> semifuture_method2(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 128 virtual folly::Future<folly::Unit> future_method2(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 129 virtual folly::SemiFuture<folly::Unit> semifuture_method2(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 130 virtual folly::Future<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_method2(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 131 virtual folly::SemiFuture<std::pair<folly::Unit, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_method2(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 132 133 #if FOLLY_HAS_COROUTINES 134 template <int = 0> co_method2(::std::int32_t p_x,const::test_cpp2::cpp_reflection::struct1 & p_y,double p_z)135 folly::coro::Task<void> co_method2(::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z) { 136 return co_method2<false>(nullptr, p_x, p_y, p_z); 137 } 138 template <int = 0> co_method2(apache::thrift::RpcOptions & rpcOptions,::std::int32_t p_x,const::test_cpp2::cpp_reflection::struct1 & p_y,double p_z)139 folly::coro::Task<void> co_method2(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z) { 140 return co_method2<true>(&rpcOptions, p_x, p_y, p_z); 141 } 142 private: 143 template <bool hasRpcOptions> co_method2(apache::thrift::RpcOptions * rpcOptions,::std::int32_t p_x,const::test_cpp2::cpp_reflection::struct1 & p_y,double p_z)144 folly::coro::Task<void> co_method2(apache::thrift::RpcOptions* rpcOptions, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z) { 145 const folly::CancellationToken& cancelToken = 146 co_await folly::coro::co_current_cancellation_token; 147 const bool cancellable = cancelToken.canBeCancelled(); 148 apache::thrift::ClientReceiveState returnState; 149 apache::thrift::ClientSyncCallback<false> callback(&returnState); 150 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); 151 auto [ctx, header] = method2Ctx(rpcOptions); 152 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>; 153 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; 154 static apache::thrift::RpcOptions defaultRpcOptions; 155 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); 156 if constexpr (hasRpcOptions) { 157 method2Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_x, p_y, p_z); 158 } else { 159 method2Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_x, p_y, p_z); 160 } 161 if (cancellable) { 162 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); 163 co_await callback.co_waitUntilDone(); 164 } else { 165 co_await callback.co_waitUntilDone(); 166 } 167 if (returnState.isException()) { 168 co_yield folly::coro::co_error(std::move(returnState.exception())); 169 } 170 returnState.resetProtocolId(protocolId); 171 returnState.resetCtx(std::move(ctx)); 172 SCOPE_EXIT { 173 if (hasRpcOptions && returnState.header()) { 174 auto* rheader = returnState.header(); 175 if (!rheader->getHeaders().empty()) { 176 rpcOptions->setReadHeaders(rheader->releaseHeaders()); 177 } 178 rpcOptions->setRoutingData(rheader->releaseRoutingData()); 179 } 180 }; 181 if (auto ew = recv_wrapped_method2(returnState)) { 182 co_yield folly::coro::co_error(std::move(ew)); 183 } 184 } 185 public: 186 #endif // FOLLY_HAS_COROUTINES 187 188 virtual void method2(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 189 190 191 static folly::exception_wrapper recv_wrapped_method2(::apache::thrift::ClientReceiveState& state); 192 static void recv_method2(::apache::thrift::ClientReceiveState& state); 193 // Mock friendly virtual instance method 194 virtual void recv_instance_method2(::apache::thrift::ClientReceiveState& state); 195 virtual folly::exception_wrapper recv_instance_wrapped_method2(::apache::thrift::ClientReceiveState& state); 196 private: 197 template <typename Protocol_, typename RpcOptions> 198 void method2T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_x, const ::test_cpp2::cpp_reflection::struct1& p_y, double p_z); 199 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> method2Ctx(apache::thrift::RpcOptions* rpcOptions); 200 public: 201 virtual void method3(std::unique_ptr<apache::thrift::RequestCallback> callback); 202 virtual void method3(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback); 203 protected: 204 void method3Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); 205 public: 206 207 virtual ::std::int32_t sync_method3(); 208 virtual ::std::int32_t sync_method3(apache::thrift::RpcOptions& rpcOptions); 209 210 virtual folly::Future<::std::int32_t> future_method3(); 211 virtual folly::SemiFuture<::std::int32_t> semifuture_method3(); 212 virtual folly::Future<::std::int32_t> future_method3(apache::thrift::RpcOptions& rpcOptions); 213 virtual folly::SemiFuture<::std::int32_t> semifuture_method3(apache::thrift::RpcOptions& rpcOptions); 214 virtual folly::Future<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_method3(apache::thrift::RpcOptions& rpcOptions); 215 virtual folly::SemiFuture<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_method3(apache::thrift::RpcOptions& rpcOptions); 216 217 #if FOLLY_HAS_COROUTINES 218 template <int = 0> co_method3()219 folly::coro::Task<::std::int32_t> co_method3() { 220 return co_method3<false>(nullptr); 221 } 222 template <int = 0> co_method3(apache::thrift::RpcOptions & rpcOptions)223 folly::coro::Task<::std::int32_t> co_method3(apache::thrift::RpcOptions& rpcOptions) { 224 return co_method3<true>(&rpcOptions); 225 } 226 private: 227 template <bool hasRpcOptions> co_method3(apache::thrift::RpcOptions * rpcOptions)228 folly::coro::Task<::std::int32_t> co_method3(apache::thrift::RpcOptions* rpcOptions) { 229 const folly::CancellationToken& cancelToken = 230 co_await folly::coro::co_current_cancellation_token; 231 const bool cancellable = cancelToken.canBeCancelled(); 232 apache::thrift::ClientReceiveState returnState; 233 apache::thrift::ClientSyncCallback<false> callback(&returnState); 234 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); 235 auto [ctx, header] = method3Ctx(rpcOptions); 236 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>; 237 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; 238 static apache::thrift::RpcOptions defaultRpcOptions; 239 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); 240 if constexpr (hasRpcOptions) { 241 method3Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); 242 } else { 243 method3Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); 244 } 245 if (cancellable) { 246 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); 247 co_await callback.co_waitUntilDone(); 248 } else { 249 co_await callback.co_waitUntilDone(); 250 } 251 if (returnState.isException()) { 252 co_yield folly::coro::co_error(std::move(returnState.exception())); 253 } 254 returnState.resetProtocolId(protocolId); 255 returnState.resetCtx(std::move(ctx)); 256 SCOPE_EXIT { 257 if (hasRpcOptions && returnState.header()) { 258 auto* rheader = returnState.header(); 259 if (!rheader->getHeaders().empty()) { 260 rpcOptions->setReadHeaders(rheader->releaseHeaders()); 261 } 262 rpcOptions->setRoutingData(rheader->releaseRoutingData()); 263 } 264 }; 265 ::std::int32_t _return; 266 if (auto ew = recv_wrapped_method3(_return, returnState)) { 267 co_yield folly::coro::co_error(std::move(ew)); 268 } 269 co_return _return; 270 } 271 public: 272 #endif // FOLLY_HAS_COROUTINES 273 274 virtual void method3(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback); 275 276 277 static folly::exception_wrapper recv_wrapped_method3(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); 278 static ::std::int32_t recv_method3(::apache::thrift::ClientReceiveState& state); 279 // Mock friendly virtual instance method 280 virtual ::std::int32_t recv_instance_method3(::apache::thrift::ClientReceiveState& state); 281 virtual folly::exception_wrapper recv_instance_wrapped_method3(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); 282 private: 283 template <typename Protocol_, typename RpcOptions> 284 void method3T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); 285 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> method3Ctx(apache::thrift::RpcOptions* rpcOptions); 286 public: 287 virtual void method4(std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 288 virtual void method4(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 289 protected: 290 void method4Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k, bool stealRpcOptions = false); 291 public: 292 293 virtual ::std::int32_t sync_method4(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 294 virtual ::std::int32_t sync_method4(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 295 296 virtual folly::Future<::std::int32_t> future_method4(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 297 virtual folly::SemiFuture<::std::int32_t> semifuture_method4(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 298 virtual folly::Future<::std::int32_t> future_method4(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 299 virtual folly::SemiFuture<::std::int32_t> semifuture_method4(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 300 virtual folly::Future<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_method4(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 301 virtual folly::SemiFuture<std::pair<::std::int32_t, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_method4(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 302 303 #if FOLLY_HAS_COROUTINES 304 template <int = 0> co_method4(::std::int32_t p_i,const::test_cpp2::cpp_reflection::struct1 & p_j,double p_k)305 folly::coro::Task<::std::int32_t> co_method4(::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k) { 306 return co_method4<false>(nullptr, p_i, p_j, p_k); 307 } 308 template <int = 0> co_method4(apache::thrift::RpcOptions & rpcOptions,::std::int32_t p_i,const::test_cpp2::cpp_reflection::struct1 & p_j,double p_k)309 folly::coro::Task<::std::int32_t> co_method4(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k) { 310 return co_method4<true>(&rpcOptions, p_i, p_j, p_k); 311 } 312 private: 313 template <bool hasRpcOptions> co_method4(apache::thrift::RpcOptions * rpcOptions,::std::int32_t p_i,const::test_cpp2::cpp_reflection::struct1 & p_j,double p_k)314 folly::coro::Task<::std::int32_t> co_method4(apache::thrift::RpcOptions* rpcOptions, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k) { 315 const folly::CancellationToken& cancelToken = 316 co_await folly::coro::co_current_cancellation_token; 317 const bool cancellable = cancelToken.canBeCancelled(); 318 apache::thrift::ClientReceiveState returnState; 319 apache::thrift::ClientSyncCallback<false> callback(&returnState); 320 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); 321 auto [ctx, header] = method4Ctx(rpcOptions); 322 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>; 323 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; 324 static apache::thrift::RpcOptions defaultRpcOptions; 325 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); 326 if constexpr (hasRpcOptions) { 327 method4Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_i, p_j, p_k); 328 } else { 329 method4Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_i, p_j, p_k); 330 } 331 if (cancellable) { 332 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); 333 co_await callback.co_waitUntilDone(); 334 } else { 335 co_await callback.co_waitUntilDone(); 336 } 337 if (returnState.isException()) { 338 co_yield folly::coro::co_error(std::move(returnState.exception())); 339 } 340 returnState.resetProtocolId(protocolId); 341 returnState.resetCtx(std::move(ctx)); 342 SCOPE_EXIT { 343 if (hasRpcOptions && returnState.header()) { 344 auto* rheader = returnState.header(); 345 if (!rheader->getHeaders().empty()) { 346 rpcOptions->setReadHeaders(rheader->releaseHeaders()); 347 } 348 rpcOptions->setRoutingData(rheader->releaseRoutingData()); 349 } 350 }; 351 ::std::int32_t _return; 352 if (auto ew = recv_wrapped_method4(_return, returnState)) { 353 co_yield folly::coro::co_error(std::move(ew)); 354 } 355 co_return _return; 356 } 357 public: 358 #endif // FOLLY_HAS_COROUTINES 359 360 virtual void method4(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 361 362 363 static folly::exception_wrapper recv_wrapped_method4(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); 364 static ::std::int32_t recv_method4(::apache::thrift::ClientReceiveState& state); 365 // Mock friendly virtual instance method 366 virtual ::std::int32_t recv_instance_method4(::apache::thrift::ClientReceiveState& state); 367 virtual folly::exception_wrapper recv_instance_wrapped_method4(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); 368 private: 369 template <typename Protocol_, typename RpcOptions> 370 void method4T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_i, const ::test_cpp2::cpp_reflection::struct1& p_j, double p_k); 371 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> method4Ctx(apache::thrift::RpcOptions* rpcOptions); 372 public: 373 virtual void method5(std::unique_ptr<apache::thrift::RequestCallback> callback); 374 virtual void method5(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback); 375 protected: 376 void method5Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); 377 public: 378 379 virtual void sync_method5(::test_cpp2::cpp_reflection::struct2& _return); 380 virtual void sync_method5(apache::thrift::RpcOptions& rpcOptions, ::test_cpp2::cpp_reflection::struct2& _return); 381 382 virtual folly::Future<::test_cpp2::cpp_reflection::struct2> future_method5(); 383 virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct2> semifuture_method5(); 384 virtual folly::Future<::test_cpp2::cpp_reflection::struct2> future_method5(apache::thrift::RpcOptions& rpcOptions); 385 virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct2> semifuture_method5(apache::thrift::RpcOptions& rpcOptions); 386 virtual folly::Future<std::pair<::test_cpp2::cpp_reflection::struct2, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_method5(apache::thrift::RpcOptions& rpcOptions); 387 virtual folly::SemiFuture<std::pair<::test_cpp2::cpp_reflection::struct2, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_method5(apache::thrift::RpcOptions& rpcOptions); 388 389 #if FOLLY_HAS_COROUTINES 390 template <int = 0> co_method5()391 folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_method5() { 392 return co_method5<false>(nullptr); 393 } 394 template <int = 0> co_method5(apache::thrift::RpcOptions & rpcOptions)395 folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_method5(apache::thrift::RpcOptions& rpcOptions) { 396 return co_method5<true>(&rpcOptions); 397 } 398 private: 399 template <bool hasRpcOptions> co_method5(apache::thrift::RpcOptions * rpcOptions)400 folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_method5(apache::thrift::RpcOptions* rpcOptions) { 401 const folly::CancellationToken& cancelToken = 402 co_await folly::coro::co_current_cancellation_token; 403 const bool cancellable = cancelToken.canBeCancelled(); 404 apache::thrift::ClientReceiveState returnState; 405 apache::thrift::ClientSyncCallback<false> callback(&returnState); 406 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); 407 auto [ctx, header] = method5Ctx(rpcOptions); 408 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>; 409 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; 410 static apache::thrift::RpcOptions defaultRpcOptions; 411 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); 412 if constexpr (hasRpcOptions) { 413 method5Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); 414 } else { 415 method5Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); 416 } 417 if (cancellable) { 418 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); 419 co_await callback.co_waitUntilDone(); 420 } else { 421 co_await callback.co_waitUntilDone(); 422 } 423 if (returnState.isException()) { 424 co_yield folly::coro::co_error(std::move(returnState.exception())); 425 } 426 returnState.resetProtocolId(protocolId); 427 returnState.resetCtx(std::move(ctx)); 428 SCOPE_EXIT { 429 if (hasRpcOptions && returnState.header()) { 430 auto* rheader = returnState.header(); 431 if (!rheader->getHeaders().empty()) { 432 rpcOptions->setReadHeaders(rheader->releaseHeaders()); 433 } 434 rpcOptions->setRoutingData(rheader->releaseRoutingData()); 435 } 436 }; 437 ::test_cpp2::cpp_reflection::struct2 _return; 438 if (auto ew = recv_wrapped_method5(_return, returnState)) { 439 co_yield folly::coro::co_error(std::move(ew)); 440 } 441 co_return _return; 442 } 443 public: 444 #endif // FOLLY_HAS_COROUTINES 445 446 virtual void method5(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback); 447 448 449 static folly::exception_wrapper recv_wrapped_method5(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 450 static void recv_method5(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 451 // Mock friendly virtual instance method 452 virtual void recv_instance_method5(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 453 virtual folly::exception_wrapper recv_instance_wrapped_method5(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 454 private: 455 template <typename Protocol_, typename RpcOptions> 456 void method5T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); 457 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> method5Ctx(apache::thrift::RpcOptions* rpcOptions); 458 public: 459 virtual void method6(std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 460 virtual void method6(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr<apache::thrift::RequestCallback> callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 461 protected: 462 void method6Impl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n, bool stealRpcOptions = false); 463 public: 464 465 virtual void sync_method6(::test_cpp2::cpp_reflection::struct2& _return, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 466 virtual void sync_method6(apache::thrift::RpcOptions& rpcOptions, ::test_cpp2::cpp_reflection::struct2& _return, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 467 468 virtual folly::Future<::test_cpp2::cpp_reflection::struct2> future_method6(::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 469 virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct2> semifuture_method6(::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 470 virtual folly::Future<::test_cpp2::cpp_reflection::struct2> future_method6(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 471 virtual folly::SemiFuture<::test_cpp2::cpp_reflection::struct2> semifuture_method6(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 472 virtual folly::Future<std::pair<::test_cpp2::cpp_reflection::struct2, std::unique_ptr<apache::thrift::transport::THeader>>> header_future_method6(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 473 virtual folly::SemiFuture<std::pair<::test_cpp2::cpp_reflection::struct2, std::unique_ptr<apache::thrift::transport::THeader>>> header_semifuture_method6(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 474 475 #if FOLLY_HAS_COROUTINES 476 template <int = 0> co_method6(::std::int32_t p_l,const::test_cpp2::cpp_reflection::struct1 & p_m,double p_n)477 folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_method6(::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n) { 478 return co_method6<false>(nullptr, p_l, p_m, p_n); 479 } 480 template <int = 0> co_method6(apache::thrift::RpcOptions & rpcOptions,::std::int32_t p_l,const::test_cpp2::cpp_reflection::struct1 & p_m,double p_n)481 folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_method6(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n) { 482 return co_method6<true>(&rpcOptions, p_l, p_m, p_n); 483 } 484 private: 485 template <bool hasRpcOptions> co_method6(apache::thrift::RpcOptions * rpcOptions,::std::int32_t p_l,const::test_cpp2::cpp_reflection::struct1 & p_m,double p_n)486 folly::coro::Task<::test_cpp2::cpp_reflection::struct2> co_method6(apache::thrift::RpcOptions* rpcOptions, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n) { 487 const folly::CancellationToken& cancelToken = 488 co_await folly::coro::co_current_cancellation_token; 489 const bool cancellable = cancelToken.canBeCancelled(); 490 apache::thrift::ClientReceiveState returnState; 491 apache::thrift::ClientSyncCallback<false> callback(&returnState); 492 auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); 493 auto [ctx, header] = method6Ctx(rpcOptions); 494 using CancellableCallback = apache::thrift::CancellableRequestClientCallback<false>; 495 auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; 496 static apache::thrift::RpcOptions defaultRpcOptions; 497 auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); 498 if constexpr (hasRpcOptions) { 499 method6Impl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_l, p_m, p_n); 500 } else { 501 method6Impl(defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), p_l, p_m, p_n); 502 } 503 if (cancellable) { 504 folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); 505 co_await callback.co_waitUntilDone(); 506 } else { 507 co_await callback.co_waitUntilDone(); 508 } 509 if (returnState.isException()) { 510 co_yield folly::coro::co_error(std::move(returnState.exception())); 511 } 512 returnState.resetProtocolId(protocolId); 513 returnState.resetCtx(std::move(ctx)); 514 SCOPE_EXIT { 515 if (hasRpcOptions && returnState.header()) { 516 auto* rheader = returnState.header(); 517 if (!rheader->getHeaders().empty()) { 518 rpcOptions->setReadHeaders(rheader->releaseHeaders()); 519 } 520 rpcOptions->setRoutingData(rheader->releaseRoutingData()); 521 } 522 }; 523 ::test_cpp2::cpp_reflection::struct2 _return; 524 if (auto ew = recv_wrapped_method6(_return, returnState)) { 525 co_yield folly::coro::co_error(std::move(ew)); 526 } 527 co_return _return; 528 } 529 public: 530 #endif // FOLLY_HAS_COROUTINES 531 532 virtual void method6(folly::Function<void (::apache::thrift::ClientReceiveState&&)> callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 533 534 535 static folly::exception_wrapper recv_wrapped_method6(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 536 static void recv_method6(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 537 // Mock friendly virtual instance method 538 virtual void recv_instance_method6(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 539 virtual folly::exception_wrapper recv_instance_wrapped_method6(::test_cpp2::cpp_reflection::struct2& _return, ::apache::thrift::ClientReceiveState& state); 540 private: 541 template <typename Protocol_, typename RpcOptions> 542 void method6T(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr<apache::thrift::transport::THeader> header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, ::std::int32_t p_l, const ::test_cpp2::cpp_reflection::struct1& p_m, double p_n); 543 std::pair<std::unique_ptr<::apache::thrift::ContextStack>, std::shared_ptr<::apache::thrift::transport::THeader>> method6Ctx(apache::thrift::RpcOptions* rpcOptions); 544 public: 545 }; 546 547 }} // test_cpp2::cpp_reflection 548