/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/interactions/src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #pragma once #include #include "thrift/compiler/test/fixtures/interactions/gen-cpp2/module_types.h" #include #include #include #include namespace apache { namespace thrift { class Cpp2RequestContext; namespace detail { namespace ac { struct ClientRequestContext; }} namespace transport { class THeader; } }} namespace cpp2 { class MyService; } // namespace cpp2 namespace apache::thrift { template <> class Client<::cpp2::MyService> : public apache::thrift::GeneratedAsyncClient { public: using apache::thrift::GeneratedAsyncClient::GeneratedAsyncClient; char const* getServiceName() const noexcept override { return "MyService"; } class MyInteraction final : public apache::thrift::InteractionHandle { using apache::thrift::InteractionHandle::InteractionHandle; friend class ::apache::thrift::Client<::cpp2::MyService>; public: char const* getServiceName() const noexcept override { return "MyService"; } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ void frobnicate(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void frobnicateImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ ::std::int32_t sync_frobnicate(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ ::std::int32_t sync_frobnicate(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ folly::SemiFuture<::std::int32_t> semifuture_frobnicate(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ folly::SemiFuture<::std::int32_t> semifuture_frobnicate(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ template folly::coro::Task<::std::int32_t> co_frobnicate() { return co_frobnicate(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ template folly::coro::Task<::std::int32_t> co_frobnicate(apache::thrift::RpcOptions& rpcOptions) { return co_frobnicate(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ folly::coro::Task<::std::int32_t> co_frobnicate() { co_return co_await folly::coro::detachOnCancel(semifuture_frobnicate()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ folly::coro::Task<::std::int32_t> co_frobnicate(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_frobnicate(rpcOptions)); } #endif private: template folly::coro::Task<::std::int32_t> co_frobnicate(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = frobnicateCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); if constexpr (hasRpcOptions) { frobnicateImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { frobnicateImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; ::std::int32_t _return; if (auto ew = recv_wrapped_frobnicate(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return _return; } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ static folly::exception_wrapper recv_wrapped_frobnicate(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "frobnicate"} */ static ::std::int32_t recv_frobnicate(::apache::thrift::ClientReceiveState& state); private: template void frobnicateT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> frobnicateCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ void ping(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void pingImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ void sync_ping(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ void sync_ping(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ folly::SemiFuture semifuture_ping(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ folly::SemiFuture semifuture_ping(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ template folly::coro::Task co_ping() { return co_ping(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ template folly::coro::Task co_ping(apache::thrift::RpcOptions& rpcOptions) { return co_ping(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ folly::coro::Task co_ping() { co_await folly::coro::detachOnCancel(semifuture_ping()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "ping"} */ folly::coro::Task co_ping(apache::thrift::RpcOptions& rpcOptions) { co_await folly::coro::detachOnCancel(semifuture_ping(rpcOptions)); } #endif private: template folly::coro::Task co_ping(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto [ctx, header] = pingCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); if constexpr (hasRpcOptions) { pingImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { pingImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } } public: #endif // FOLLY_HAS_COROUTINES private: template void pingT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> pingCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ void truthify(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void truthifyImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ apache::thrift::ClientBufferedStream sync_truthify(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ apache::thrift::ClientBufferedStream sync_truthify(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ folly::SemiFuture> semifuture_truthify(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ folly::SemiFuture> semifuture_truthify(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ template folly::coro::Task> co_truthify() { return co_truthify(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ template folly::coro::Task> co_truthify(apache::thrift::RpcOptions& rpcOptions) { return co_truthify(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ folly::coro::Task> co_truthify() { co_return co_await folly::coro::detachOnCancel(semifuture_truthify()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ folly::coro::Task> co_truthify(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_truthify(rpcOptions)); } #endif private: template folly::coro::Task> co_truthify(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = truthifyCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback), hasRpcOptions ? rpcOptions->getBufferOptions() : defaultRpcOptions->getBufferOptions()); if constexpr (hasRpcOptions) { truthifyImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { truthifyImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; apache::thrift::ClientBufferedStream _return; if (auto ew = recv_wrapped_truthify(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return _return; } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ static folly::exception_wrapper recv_wrapped_truthify(apache::thrift::ClientBufferedStream& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "truthify"} */ static apache::thrift::ClientBufferedStream recv_truthify(::apache::thrift::ClientReceiveState& state); private: template void truthifyT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> truthifyCtx(apache::thrift::RpcOptions* rpcOptions); public: protected: void encodeImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback, bool stealRpcOptions = false); public: #if FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "encode"} */ folly::coro::Task, ::std::string, ::std::string>> co_encode(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "encode"} */ folly::coro::Task, ::std::string, ::std::string>> co_encode(apache::thrift::RpcOptions& rpcOptions); #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "encode"} */ static folly::exception_wrapper recv_wrapped_encode(apache::thrift::ResponseAndClientSink<::std::set<::std::int32_t>, ::std::string, ::std::string>& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteraction", "function": "encode"} */ static apache::thrift::ResponseAndClientSink<::std::set<::std::int32_t>, ::std::string, ::std::string> recv_encode(::apache::thrift::ClientReceiveState& state); private: template void encodeT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> encodeCtx(apache::thrift::RpcOptions* rpcOptions); public: };class MyInteractionFast final : public apache::thrift::InteractionHandle { using apache::thrift::InteractionHandle::InteractionHandle; friend class ::apache::thrift::Client<::cpp2::MyService>; public: char const* getServiceName() const noexcept override { return "MyService"; } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ void frobnicate(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void frobnicateImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ ::std::int32_t sync_frobnicate(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ ::std::int32_t sync_frobnicate(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ folly::SemiFuture<::std::int32_t> semifuture_frobnicate(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ folly::SemiFuture<::std::int32_t> semifuture_frobnicate(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ template folly::coro::Task<::std::int32_t> co_frobnicate() { return co_frobnicate(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ template folly::coro::Task<::std::int32_t> co_frobnicate(apache::thrift::RpcOptions& rpcOptions) { return co_frobnicate(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ folly::coro::Task<::std::int32_t> co_frobnicate() { co_return co_await folly::coro::detachOnCancel(semifuture_frobnicate()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ folly::coro::Task<::std::int32_t> co_frobnicate(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_frobnicate(rpcOptions)); } #endif private: template folly::coro::Task<::std::int32_t> co_frobnicate(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = frobnicateCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); if constexpr (hasRpcOptions) { frobnicateImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { frobnicateImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; ::std::int32_t _return; if (auto ew = recv_wrapped_frobnicate(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return _return; } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ static folly::exception_wrapper recv_wrapped_frobnicate(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "frobnicate"} */ static ::std::int32_t recv_frobnicate(::apache::thrift::ClientReceiveState& state); private: template void frobnicateT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> frobnicateCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ void ping(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void pingImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ void sync_ping(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ void sync_ping(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ folly::SemiFuture semifuture_ping(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ folly::SemiFuture semifuture_ping(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ template folly::coro::Task co_ping() { return co_ping(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ template folly::coro::Task co_ping(apache::thrift::RpcOptions& rpcOptions) { return co_ping(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ folly::coro::Task co_ping() { co_await folly::coro::detachOnCancel(semifuture_ping()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "ping"} */ folly::coro::Task co_ping(apache::thrift::RpcOptions& rpcOptions) { co_await folly::coro::detachOnCancel(semifuture_ping(rpcOptions)); } #endif private: template folly::coro::Task co_ping(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto [ctx, header] = pingCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); if constexpr (hasRpcOptions) { pingImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { pingImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } } public: #endif // FOLLY_HAS_COROUTINES private: template void pingT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> pingCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ void truthify(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void truthifyImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ apache::thrift::ClientBufferedStream sync_truthify(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ apache::thrift::ClientBufferedStream sync_truthify(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ folly::SemiFuture> semifuture_truthify(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ folly::SemiFuture> semifuture_truthify(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ template folly::coro::Task> co_truthify() { return co_truthify(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ template folly::coro::Task> co_truthify(apache::thrift::RpcOptions& rpcOptions) { return co_truthify(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ folly::coro::Task> co_truthify() { co_return co_await folly::coro::detachOnCancel(semifuture_truthify()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ folly::coro::Task> co_truthify(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_truthify(rpcOptions)); } #endif private: template folly::coro::Task> co_truthify(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = truthifyCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback), hasRpcOptions ? rpcOptions->getBufferOptions() : defaultRpcOptions->getBufferOptions()); if constexpr (hasRpcOptions) { truthifyImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { truthifyImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; apache::thrift::ClientBufferedStream _return; if (auto ew = recv_wrapped_truthify(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return _return; } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ static folly::exception_wrapper recv_wrapped_truthify(apache::thrift::ClientBufferedStream& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "truthify"} */ static apache::thrift::ClientBufferedStream recv_truthify(::apache::thrift::ClientReceiveState& state); private: template void truthifyT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> truthifyCtx(apache::thrift::RpcOptions* rpcOptions); public: protected: void encodeImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback, bool stealRpcOptions = false); public: #if FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "encode"} */ folly::coro::Task, ::std::string, ::std::string>> co_encode(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "encode"} */ folly::coro::Task, ::std::string, ::std::string>> co_encode(apache::thrift::RpcOptions& rpcOptions); #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "encode"} */ static folly::exception_wrapper recv_wrapped_encode(apache::thrift::ResponseAndClientSink<::std::set<::std::int32_t>, ::std::string, ::std::string>& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyInteractionFast", "function": "encode"} */ static apache::thrift::ResponseAndClientSink<::std::set<::std::int32_t>, ::std::string, ::std::string> recv_encode(::apache::thrift::ClientReceiveState& state); private: template void encodeT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> encodeCtx(apache::thrift::RpcOptions* rpcOptions); public: };class SerialInteraction final : public apache::thrift::InteractionHandle { using apache::thrift::InteractionHandle::InteractionHandle; friend class ::apache::thrift::Client<::cpp2::MyService>; public: char const* getServiceName() const noexcept override { return "MyService"; } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ void frobnicate(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void frobnicateImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ void sync_frobnicate(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ void sync_frobnicate(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ folly::SemiFuture semifuture_frobnicate(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ folly::SemiFuture semifuture_frobnicate(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ template folly::coro::Task co_frobnicate() { return co_frobnicate(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ template folly::coro::Task co_frobnicate(apache::thrift::RpcOptions& rpcOptions) { return co_frobnicate(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ folly::coro::Task co_frobnicate() { co_await folly::coro::detachOnCancel(semifuture_frobnicate()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ folly::coro::Task co_frobnicate(apache::thrift::RpcOptions& rpcOptions) { co_await folly::coro::detachOnCancel(semifuture_frobnicate(rpcOptions)); } #endif private: template folly::coro::Task co_frobnicate(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = frobnicateCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); if constexpr (hasRpcOptions) { frobnicateImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { frobnicateImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; if (auto ew = recv_wrapped_frobnicate(returnState)) { co_yield folly::coro::co_error(std::move(ew)); } } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ static folly::exception_wrapper recv_wrapped_frobnicate(::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "SerialInteraction", "function": "frobnicate"} */ static void recv_frobnicate(::apache::thrift::ClientReceiveState& state); private: template void frobnicateT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> frobnicateCtx(apache::thrift::RpcOptions* rpcOptions); public: }; /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "createMyInteraction"} */ MyInteraction createMyInteraction(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "createMyInteractionFast"} */ MyInteractionFast createMyInteractionFast(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "createSerialInteraction"} */ SerialInteraction createSerialInteraction(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual void foo(std::unique_ptr callback); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual void foo(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void fooImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual void sync_foo(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual void sync_foo(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual folly::Future future_foo(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual folly::SemiFuture semifuture_foo(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual folly::Future future_foo(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual folly::SemiFuture semifuture_foo(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual folly::Future>> header_future_foo(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual folly::SemiFuture>> header_semifuture_foo(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ template folly::coro::Task co_foo() { return co_foo(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ template folly::coro::Task co_foo(apache::thrift::RpcOptions& rpcOptions) { return co_foo(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ folly::coro::Task co_foo() { co_await folly::coro::detachOnCancel(semifuture_foo()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ folly::coro::Task co_foo(apache::thrift::RpcOptions& rpcOptions) { co_await folly::coro::detachOnCancel(semifuture_foo(rpcOptions)); } #endif private: template folly::coro::Task co_foo(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = fooCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); if constexpr (hasRpcOptions) { fooImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fooImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; if (auto ew = recv_wrapped_foo(returnState)) { co_yield folly::coro::co_error(std::move(ew)); } } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual void foo(folly::Function callback); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ static folly::exception_wrapper recv_wrapped_foo(::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ static void recv_foo(::apache::thrift::ClientReceiveState& state); // Mock friendly virtual instance method /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual void recv_instance_foo(::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "foo"} */ virtual folly::exception_wrapper recv_instance_wrapped_foo(::apache::thrift::ClientReceiveState& state); private: template void fooT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> fooCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ void interact(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const apache::thrift::InteractionHandle& handle, ::std::int32_t p_arg); protected: void interactImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle, ::std::int32_t p_arg, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ apache::thrift::Client<::cpp2::MyService>::MyInteraction sync_interact(::std::int32_t p_arg); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ apache::thrift::Client<::cpp2::MyService>::MyInteraction sync_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ folly::SemiFuture::MyInteraction> semifuture_interact(::std::int32_t p_arg); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ folly::SemiFuture::MyInteraction> semifuture_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ std::pair< apache::thrift::Client<::cpp2::MyService>::MyInteraction, folly::SemiFuture > eager_semifuture_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ template folly::coro::Task::MyInteraction> co_interact(::std::int32_t p_arg) { return co_interact(nullptr, p_arg); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ template folly::coro::Task::MyInteraction> co_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg) { return co_interact(&rpcOptions, p_arg); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ folly::coro::Task::MyInteraction> co_interact(::std::int32_t p_arg) { co_await folly::coro::detachOnCancel(semifuture_interact(p_arg)); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ folly::coro::Task::MyInteraction> co_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg) { co_await folly::coro::detachOnCancel(semifuture_interact(rpcOptions, p_arg)); } #endif private: template folly::coro::Task::MyInteraction> co_interact(apache::thrift::RpcOptions* rpcOptions, ::std::int32_t p_arg) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = interactCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); MyInteraction handle(channel_, "MyInteraction"); if constexpr (hasRpcOptions) { interactImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), handle, p_arg); } else { interactImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), handle, p_arg); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; if (auto ew = recv_wrapped_interact(returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return handle; } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ static folly::exception_wrapper recv_wrapped_interact(::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interact"} */ static void recv_interact(::apache::thrift::ClientReceiveState& state); private: template void interactT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle, ::std::int32_t p_arg); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> interactCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ void interactFast(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const apache::thrift::InteractionHandle& handle); protected: void interactFastImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ std::pair::MyInteractionFast, ::std::int32_t> sync_interactFast(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ std::pair::MyInteractionFast, ::std::int32_t> sync_interactFast(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ folly::SemiFuture::MyInteractionFast, ::std::int32_t>> semifuture_interactFast(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ folly::SemiFuture::MyInteractionFast, ::std::int32_t>> semifuture_interactFast(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ std::pair< apache::thrift::Client<::cpp2::MyService>::MyInteractionFast, folly::SemiFuture<::std::int32_t> > eager_semifuture_interactFast(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ template folly::coro::Task::MyInteractionFast, ::std::int32_t>> co_interactFast() { return co_interactFast(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ template folly::coro::Task::MyInteractionFast, ::std::int32_t>> co_interactFast(apache::thrift::RpcOptions& rpcOptions) { return co_interactFast(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ folly::coro::Task::MyInteractionFast, ::std::int32_t>> co_interactFast() { co_return co_await folly::coro::detachOnCancel(semifuture_interactFast()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ folly::coro::Task::MyInteractionFast, ::std::int32_t>> co_interactFast(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_interactFast(rpcOptions)); } #endif private: template folly::coro::Task::MyInteractionFast, ::std::int32_t>> co_interactFast(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = interactFastCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback); MyInteractionFast handle(channel_, "MyInteractionFast"); if constexpr (hasRpcOptions) { interactFastImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), handle); } else { interactFastImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), handle); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; ::std::int32_t _return; if (auto ew = recv_wrapped_interactFast(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return std::make_pair(std::move(handle), std::move(_return)); } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ static folly::exception_wrapper recv_wrapped_interactFast(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "interactFast"} */ static ::std::int32_t recv_interactFast(::apache::thrift::ClientReceiveState& state); private: template void interactFastT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> interactFastCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ void serialize(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const apache::thrift::InteractionHandle& handle); protected: void serializeImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, const apache::thrift::InteractionHandle& handle, bool stealRpcOptions = false); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ std::pair::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>> sync_serialize(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ std::pair::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>> sync_serialize(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ folly::SemiFuture::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> semifuture_serialize(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ folly::SemiFuture::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> semifuture_serialize(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ std::pair< apache::thrift::Client<::cpp2::MyService>::SerialInteraction, folly::SemiFuture> > eager_semifuture_serialize(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ template folly::coro::Task::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> co_serialize() { return co_serialize(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ template folly::coro::Task::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> co_serialize(apache::thrift::RpcOptions& rpcOptions) { return co_serialize(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ folly::coro::Task::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> co_serialize() { co_return co_await folly::coro::detachOnCancel(semifuture_serialize()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ folly::coro::Task::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> co_serialize(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_serialize(rpcOptions)); } #endif private: template folly::coro::Task::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> co_serialize(apache::thrift::RpcOptions* rpcOptions) { const folly::CancellationToken& cancelToken = co_await folly::coro::co_current_cancellation_token; const bool cancellable = cancelToken.canBeCancelled(); apache::thrift::ClientReceiveState returnState; apache::thrift::ClientCoroCallback callback(&returnState, co_await folly::coro::co_current_executor); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto [ctx, header] = serializeCtx(rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; static apache::thrift::RpcOptions* defaultRpcOptions = new apache::thrift::RpcOptions(); auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback), hasRpcOptions ? rpcOptions->getBufferOptions() : defaultRpcOptions->getBufferOptions()); SerialInteraction handle(channel_, "SerialInteraction"); if constexpr (hasRpcOptions) { serializeImpl(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), handle); } else { serializeImpl(*defaultRpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback), handle); } if (cancellable) { folly::CancellationCallback cb(cancelToken, [&] { CancellableCallback::cancel(std::move(cancellableCallback)); }); co_await callback.co_waitUntilDone(); } else { co_await callback.co_waitUntilDone(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctx)); SCOPE_EXIT { if (hasRpcOptions && returnState.header()) { auto* rheader = returnState.header(); if (!rheader->getHeaders().empty()) { rpcOptions->setReadHeaders(rheader->releaseHeaders()); } rpcOptions->setRoutingData(rheader->releaseRoutingData()); } }; apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t> _return; if (auto ew = recv_wrapped_serialize(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return std::make_pair(std::move(handle), std::move(_return)); } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ static folly::exception_wrapper recv_wrapped_serialize(apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "MyService", "function": "serialize"} */ static apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t> recv_serialize(::apache::thrift::ClientReceiveState& state); private: template void serializeT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, const apache::thrift::InteractionHandle& handle); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> serializeCtx(apache::thrift::RpcOptions* rpcOptions); public: }; } // namespace apache::thrift namespace cpp2 { using MyServiceAsyncClient [[deprecated("Use apache::thrift::Client instead")]] = ::apache::thrift::Client; } // namespace cpp2