/** * 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 "thrift/compiler/test/fixtures/interactions/gen-cpp2/shared_types.h" #include #include #include namespace apache { namespace thrift { class Cpp2RequestContext; namespace detail { namespace ac { struct ClientRequestContext; }} namespace transport { class THeader; } }} namespace cpp2 { class InteractWithShared; } // namespace cpp2 namespace apache::thrift { template <> class Client<::cpp2::InteractWithShared> : public apache::thrift::GeneratedAsyncClient { public: using apache::thrift::GeneratedAsyncClient::GeneratedAsyncClient; char const* getServiceName() const noexcept override { return "InteractWithShared"; } class MyInteraction final : public apache::thrift::InteractionHandle { using apache::thrift::InteractionHandle::InteractionHandle; friend class ::apache::thrift::Client<::cpp2::InteractWithShared>; public: char const* getServiceName() const noexcept override { return "InteractWithShared"; } /** 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 fbthrift_serialize_and_send_frobnicate(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); const bool shouldProcessClientInterceptors = ctx && ctx->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnRequest(); } if constexpr (hasRpcOptions) { fbthrift_serialize_and_send_frobnicate(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fbthrift_serialize_and_send_frobnicate(*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 (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnResponse(); } 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 apache::thrift::SerializedRequest fbthrift_serialize_frobnicate(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_frobnicate(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, 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 fbthrift_serialize_and_send_ping(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); const bool shouldProcessClientInterceptors = ctx && ctx->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnRequest(); } if constexpr (hasRpcOptions) { fbthrift_serialize_and_send_ping(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fbthrift_serialize_and_send_ping(*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 (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnResponse(); } if (returnState.isException()) { co_yield folly::coro::co_error(std::move(returnState.exception())); } } public: #endif // FOLLY_HAS_COROUTINES private: template apache::thrift::SerializedRequest fbthrift_serialize_ping(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_ping(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, 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 fbthrift_serialize_and_send_truthify(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()); const bool shouldProcessClientInterceptors = ctx && ctx->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnRequest(); } if constexpr (hasRpcOptions) { fbthrift_serialize_and_send_truthify(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fbthrift_serialize_and_send_truthify(*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 (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnResponse(); } 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 apache::thrift::SerializedRequest fbthrift_serialize_truthify(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_truthify(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, 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 fbthrift_serialize_and_send_encode(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 apache::thrift::SerializedRequest fbthrift_serialize_encode(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_encode(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::SinkClientCallback* callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> encodeCtx(apache::thrift::RpcOptions* rpcOptions); public: };class SharedInteraction final : public apache::thrift::InteractionHandle { using apache::thrift::InteractionHandle::InteractionHandle; friend class ::apache::thrift::Client<::cpp2::InteractWithShared>; public: char const* getServiceName() const noexcept override { return "InteractWithShared"; } /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ void init(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void fbthrift_serialize_and_send_init(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ ::std::int32_t sync_init(); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ ::std::int32_t sync_init(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ folly::SemiFuture<::std::int32_t> semifuture_init(); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ folly::SemiFuture<::std::int32_t> semifuture_init(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ template folly::coro::Task<::std::int32_t> co_init() { return co_init(nullptr); } /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ template folly::coro::Task<::std::int32_t> co_init(apache::thrift::RpcOptions& rpcOptions) { return co_init(&rpcOptions); } #else /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ folly::coro::Task<::std::int32_t> co_init() { co_return co_await folly::coro::detachOnCancel(semifuture_init()); } /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ folly::coro::Task<::std::int32_t> co_init(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_init(rpcOptions)); } #endif private: template folly::coro::Task<::std::int32_t> co_init(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] = initCtx(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); const bool shouldProcessClientInterceptors = ctx && ctx->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnRequest(); } if constexpr (hasRpcOptions) { fbthrift_serialize_and_send_init(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fbthrift_serialize_and_send_init(*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 (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnResponse(); } 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_init(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return _return; } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ static folly::exception_wrapper recv_wrapped_init(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "init"} */ static ::std::int32_t recv_init(::apache::thrift::ClientReceiveState& state); private: template apache::thrift::SerializedRequest fbthrift_serialize_init(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_init(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> initCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ void do_something(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void fbthrift_serialize_and_send_do_something(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ void sync_do_something(::thrift::shared_interactions::DoSomethingResult& _return); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ void sync_do_something(apache::thrift::RpcOptions& rpcOptions, ::thrift::shared_interactions::DoSomethingResult& _return); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> semifuture_do_something(); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> semifuture_do_something(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ template folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_something() { return co_do_something(nullptr); } /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ template folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_something(apache::thrift::RpcOptions& rpcOptions) { return co_do_something(&rpcOptions); } #else /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_something() { co_return co_await folly::coro::detachOnCancel(semifuture_do_something()); } /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_something(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_do_something(rpcOptions)); } #endif private: template folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_something(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] = do_somethingCtx(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); const bool shouldProcessClientInterceptors = ctx && ctx->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnRequest(); } if constexpr (hasRpcOptions) { fbthrift_serialize_and_send_do_something(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fbthrift_serialize_and_send_do_something(*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 (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnResponse(); } 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()); } }; ::thrift::shared_interactions::DoSomethingResult _return; if (auto ew = recv_wrapped_do_something(_return, returnState)) { co_yield folly::coro::co_error(std::move(ew)); } co_return _return; } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ static folly::exception_wrapper recv_wrapped_do_something(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "do_something"} */ static void recv_do_something(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state); private: template apache::thrift::SerializedRequest fbthrift_serialize_do_something(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_do_something(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> do_somethingCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ void tear_down(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void fbthrift_serialize_and_send_tear_down(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions = false); public: /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ void sync_tear_down(); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ void sync_tear_down(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ folly::SemiFuture semifuture_tear_down(); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ folly::SemiFuture semifuture_tear_down(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ template folly::coro::Task co_tear_down() { return co_tear_down(nullptr); } /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ template folly::coro::Task co_tear_down(apache::thrift::RpcOptions& rpcOptions) { return co_tear_down(&rpcOptions); } #else /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ folly::coro::Task co_tear_down() { co_await folly::coro::detachOnCancel(semifuture_tear_down()); } /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ folly::coro::Task co_tear_down(apache::thrift::RpcOptions& rpcOptions) { co_await folly::coro::detachOnCancel(semifuture_tear_down(rpcOptions)); } #endif private: template folly::coro::Task co_tear_down(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] = tear_downCtx(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); const bool shouldProcessClientInterceptors = ctx && ctx->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnRequest(); } if constexpr (hasRpcOptions) { fbthrift_serialize_and_send_tear_down(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fbthrift_serialize_and_send_tear_down(*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 (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnResponse(); } 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_tear_down(returnState)) { co_yield folly::coro::co_error(std::move(ew)); } } public: #endif // FOLLY_HAS_COROUTINES /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ static folly::exception_wrapper recv_wrapped_tear_down(::apache::thrift::ClientReceiveState& state); /** Glean {"file": "shared.thrift", "service": "SharedInteraction", "function": "tear_down"} */ static void recv_tear_down(::apache::thrift::ClientReceiveState& state); private: template apache::thrift::SerializedRequest fbthrift_serialize_tear_down(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_tear_down(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> tear_downCtx(apache::thrift::RpcOptions* rpcOptions); public: }; /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual void do_some_similar_things(std::unique_ptr callback); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual void do_some_similar_things(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback); protected: void fbthrift_serialize_and_send_do_some_similar_things(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": "InteractWithShared", "function": "do_some_similar_things"} */ virtual void sync_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual void sync_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions, ::thrift::shared_interactions::DoSomethingResult& _return); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual folly::Future<::thrift::shared_interactions::DoSomethingResult> future_do_some_similar_things(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> semifuture_do_some_similar_things(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual folly::Future<::thrift::shared_interactions::DoSomethingResult> future_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> semifuture_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual folly::Future>> header_future_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual folly::SemiFuture>> header_semifuture_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions); #if FOLLY_HAS_COROUTINES #if __clang__ /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ template folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_some_similar_things() { return co_do_some_similar_things(nullptr); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ template folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions) { return co_do_some_similar_things(&rpcOptions); } #else /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_some_similar_things() { co_return co_await folly::coro::detachOnCancel(semifuture_do_some_similar_things()); } /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions) { co_return co_await folly::coro::detachOnCancel(semifuture_do_some_similar_things(rpcOptions)); } #endif private: template folly::coro::Task<::thrift::shared_interactions::DoSomethingResult> co_do_some_similar_things(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] = do_some_similar_thingsCtx(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); const bool shouldProcessClientInterceptors = ctx && ctx->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnRequest(); } if constexpr (hasRpcOptions) { fbthrift_serialize_and_send_do_some_similar_things(*rpcOptions, std::move(header), ctx.get(), std::move(wrappedCallback)); } else { fbthrift_serialize_and_send_do_some_similar_things(*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 (shouldProcessClientInterceptors) { co_await ctx->processClientInterceptorsOnResponse(); } 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()); } }; ::thrift::shared_interactions::DoSomethingResult _return; if (auto ew = recv_wrapped_do_some_similar_things(_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": "InteractWithShared", "function": "do_some_similar_things"} */ virtual void do_some_similar_things(folly::Function callback); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ static folly::exception_wrapper recv_wrapped_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ static void recv_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state); // Mock friendly virtual instance method /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual void recv_instance_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "do_some_similar_things"} */ virtual folly::exception_wrapper recv_instance_wrapped_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state); private: template apache::thrift::SerializedRequest fbthrift_serialize_do_some_similar_things(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack); template void fbthrift_send_do_some_similar_things(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback); std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> do_some_similar_thingsCtx(apache::thrift::RpcOptions* rpcOptions); public: /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "createMyInteraction"} */ MyInteraction createMyInteraction(); /** Glean {"file": "thrift/compiler/test/fixtures/interactions/src/module.thrift", "service": "InteractWithShared", "function": "createshared.SharedInteraction"} */ SharedInteraction createshared.SharedInteraction(); }; } // namespace apache::thrift namespace cpp2 { using InteractWithSharedAsyncClient [[deprecated("Use apache::thrift::Client instead")]] = ::apache::thrift::Client; } // namespace cpp2