/** * 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 */ #include "thrift/compiler/test/fixtures/interactions/gen-cpp2/InteractWithSharedAsyncClient.h" #include namespace cpp2 { typedef apache::thrift::ThriftPresult InteractWithShared_do_some_similar_things_pargs; typedef apache::thrift::ThriftPresult> InteractWithShared_do_some_similar_things_presult; } // namespace cpp2 template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::fbthrift_serialize_do_some_similar_things(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::cpp2::InteractWithShared_do_some_similar_things_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "do_some_similar_things", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::fbthrift_send_do_some_similar_things(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback) { static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "do_some_similar_things", ::apache::thrift::FunctionQualifier::Unspecified, "InteractWithShared"); apache::thrift::clientSendT(std::move(request), std::forward(rpcOptions), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } void apache::thrift::Client<::cpp2::InteractWithShared>::do_some_similar_things(std::unique_ptr callback) { ::apache::thrift::RpcOptions rpcOptions; do_some_similar_things(rpcOptions, std::move(callback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::do_some_similar_things(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = do_some_similar_thingsCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_do_some_similar_things(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::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) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_do_some_similar_things(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_do_some_similar_things(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_do_some_similar_things(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::do_some_similar_thingsCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.do_some_similar_things", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::InteractWithShared>::sync_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return) { ::apache::thrift::RpcOptions rpcOptions; sync_do_some_similar_things(rpcOptions, _return); } void apache::thrift::Client<::cpp2::InteractWithShared>::sync_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions, ::thrift::shared_interactions::DoSomethingResult& _return) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = do_some_similar_thingsCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); #if FOLLY_HAS_COROUTINES const bool shouldProcessClientInterceptors = ctxAndHeader.first && ctxAndHeader.first->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnRequest()); } #endif callback.waitUntilDone( evb, [&] { fbthrift_serialize_and_send_do_some_similar_things(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); #if FOLLY_HAS_COROUTINES if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnResponse()); } #endif if (returnState.isException()) { returnState.exception().throw_exception(); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { recv_do_some_similar_things(_return, returnState); }); } folly::Future<::thrift::shared_interactions::DoSomethingResult> apache::thrift::Client<::cpp2::InteractWithShared>::future_do_some_similar_things() { ::apache::thrift::RpcOptions rpcOptions; return future_do_some_similar_things(rpcOptions); } folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> apache::thrift::Client<::cpp2::InteractWithShared>::semifuture_do_some_similar_things() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_do_some_similar_things(rpcOptions); } folly::Future<::thrift::shared_interactions::DoSomethingResult> apache::thrift::Client<::cpp2::InteractWithShared>::future_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions) { using CallbackHelper = apache::thrift::detail::FutureCallbackHelper<::thrift::shared_interactions::DoSomethingResult>; folly::Promise promise; auto future = promise.getFuture(); auto callback = std::make_unique>(std::move(promise), recv_wrapped_do_some_similar_things, channel_); do_some_similar_things(rpcOptions, std::move(callback)); return std::move(future).thenValue(CallbackHelper::extractResult); } folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> apache::thrift::Client<::cpp2::InteractWithShared>::semifuture_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_do_some_similar_things, channel_); auto callback = std::move(callbackAndFuture.first); do_some_similar_things(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } folly::Future>> apache::thrift::Client<::cpp2::InteractWithShared>::header_future_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions) { using CallbackHelper = apache::thrift::detail::FutureCallbackHelper>>; folly::Promise promise; auto future = promise.getFuture(); auto callback = std::make_unique>(std::move(promise), recv_wrapped_do_some_similar_things, channel_); do_some_similar_things(rpcOptions, std::move(callback)); return std::move(future).thenValue(CallbackHelper::extractResult); } folly::SemiFuture>> apache::thrift::Client<::cpp2::InteractWithShared>::header_semifuture_do_some_similar_things(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeHeaderSemiFutureCallback(recv_wrapped_do_some_similar_things, channel_); auto callback = std::move(callbackAndFuture.first); do_some_similar_things(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } void apache::thrift::Client<::cpp2::InteractWithShared>::do_some_similar_things(folly::Function callback) { do_some_similar_things(std::make_unique(std::move(callback))); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::recv_wrapped_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = ::cpp2::InteractWithShared_do_some_similar_things_presult; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } void apache::thrift::Client<::cpp2::InteractWithShared>::recv_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_do_some_similar_things(_return, state); if (ew) { ew.throw_exception(); } } void apache::thrift::Client<::cpp2::InteractWithShared>::recv_instance_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state) { return recv_do_some_similar_things(_return, state); } folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::recv_instance_wrapped_do_some_similar_things(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state) { return recv_wrapped_do_some_similar_things(_return, state); } apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction apache::thrift::Client<::cpp2::InteractWithShared>::createMyInteraction() { return MyInteraction(channel_, "MyInteraction"); } apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction apache::thrift::Client<::cpp2::InteractWithShared>::createshared.SharedInteraction() { return SharedInteraction(channel_, "SharedInteraction"); } namespace cpp2 { typedef apache::thrift::ThriftPresult InteractWithShared_MyInteraction_frobnicate_pargs; typedef apache::thrift::ThriftPresult, apache::thrift::FieldData<1, ::apache::thrift::type_class::structure, ::cpp2::CustomException>> InteractWithShared_MyInteraction_frobnicate_presult; typedef apache::thrift::ThriftPresult InteractWithShared_MyInteraction_ping_pargs; typedef apache::thrift::ThriftPresult InteractWithShared_MyInteraction_truthify_pargs; typedef apache::thrift::ThriftPResultStream< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult> > InteractWithShared_MyInteraction_truthify_presult; typedef apache::thrift::ThriftPresult InteractWithShared_MyInteraction_encode_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, ::std::set<::std::int32_t>*>>, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > InteractWithShared_MyInteraction_encode_presult; } // namespace cpp2 template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_frobnicate(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::cpp2::InteractWithShared_MyInteraction_frobnicate_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "MyInteraction.frobnicate", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_send_frobnicate(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.frobnicate", ::apache::thrift::FunctionQualifier::Unspecified, "InteractWithShared", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(std::move(request), std::move(rpcOpts), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_ping(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::cpp2::InteractWithShared_MyInteraction_ping_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "MyInteraction.ping", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_send_ping(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.ping", ::apache::thrift::FunctionQualifier::OneWay, "InteractWithShared", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(std::move(request), std::move(rpcOpts), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_truthify(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::cpp2::InteractWithShared_MyInteraction_truthify_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "MyInteraction.truthify", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_send_truthify(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::StreamClientCallback* callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.truthify", ::apache::thrift::FunctionQualifier::Unspecified, "InteractWithShared", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(std::move(request), std::move(rpcOpts), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_encode(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::cpp2::InteractWithShared_MyInteraction_encode_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "MyInteraction.encode", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_send_encode(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::SinkClientCallback* callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.encode", ::apache::thrift::FunctionQualifier::Unspecified, "InteractWithShared", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(std::move(request), std::move(rpcOpts), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::frobnicate(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = frobnicateCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_frobnicate(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_and_send_frobnicate(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_frobnicate(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_frobnicate(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_frobnicate(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::frobnicateCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.MyInteraction.frobnicate", *header); return {std::move(ctx), std::move(header)}; } ::std::int32_t apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::sync_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; return sync_frobnicate(rpcOptions); } ::std::int32_t apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::sync_frobnicate(apache::thrift::RpcOptions& rpcOptions) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = frobnicateCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); #if FOLLY_HAS_COROUTINES const bool shouldProcessClientInterceptors = ctxAndHeader.first && ctxAndHeader.first->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnRequest()); } #endif callback.waitUntilDone( evb, [&] { fbthrift_serialize_and_send_frobnicate(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); #if FOLLY_HAS_COROUTINES if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnResponse()); } #endif if (returnState.isException()) { returnState.exception().throw_exception(); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { return recv_frobnicate(returnState); }); } folly::SemiFuture<::std::int32_t> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::semifuture_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_frobnicate(rpcOptions); } folly::SemiFuture<::std::int32_t> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::semifuture_frobnicate(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_frobnicate, channel_); auto callback = std::move(callbackAndFuture.first); frobnicate(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::recv_wrapped_frobnicate(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = ::cpp2::InteractWithShared_MyInteraction_frobnicate_presult; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } ::std::int32_t apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::recv_frobnicate(::apache::thrift::ClientReceiveState& state) { ::std::int32_t _return; auto ew = recv_wrapped_frobnicate(_return, state); if (ew) { ew.throw_exception(); } return _return; } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::ping(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = pingCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_ping(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_and_send_ping(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_ping(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_ping(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_ping(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::pingCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.MyInteraction.ping", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::sync_ping() { ::apache::thrift::RpcOptions rpcOptions; sync_ping(rpcOptions); } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::sync_ping(apache::thrift::RpcOptions& rpcOptions) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = pingCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); #if FOLLY_HAS_COROUTINES const bool shouldProcessClientInterceptors = ctxAndHeader.first && ctxAndHeader.first->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnRequest()); } #endif callback.waitUntilDone( evb, [&] { fbthrift_serialize_and_send_ping(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); #if FOLLY_HAS_COROUTINES if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnResponse()); } #endif if (returnState.isException()) { returnState.exception().throw_exception(); } } folly::SemiFuture apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::semifuture_ping() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_ping(rpcOptions); } folly::SemiFuture apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::semifuture_ping(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeOneWaySemiFutureCallback(channel_); auto callback = std::move(callbackAndFuture.first); ping(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::truthify(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = truthifyCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); auto streamCallback = apache::thrift::createStreamClientCallback(std::move(wrappedCallback), rpcOptions.getBufferOptions()); fbthrift_serialize_and_send_truthify(rpcOptions, std::move(header), contextStack, std::move(streamCallback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_and_send_truthify(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, bool stealRpcOptions) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_truthify(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_truthify(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_truthify(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::truthifyCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.MyInteraction.truthify", *header); return {std::move(ctx), std::move(header)}; } apache::thrift::ClientBufferedStream apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::sync_truthify() { ::apache::thrift::RpcOptions rpcOptions; return sync_truthify(rpcOptions); } apache::thrift::ClientBufferedStream apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::sync_truthify(apache::thrift::RpcOptions& rpcOptions) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = truthifyCtx(&rpcOptions); auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(&callback), rpcOptions.getBufferOptions()); #if FOLLY_HAS_COROUTINES const bool shouldProcessClientInterceptors = ctxAndHeader.first && ctxAndHeader.first->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnRequest()); } #endif callback.waitUntilDone( evb, [&] { fbthrift_serialize_and_send_truthify(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); #if FOLLY_HAS_COROUTINES if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnResponse()); } #endif if (returnState.isException()) { returnState.exception().throw_exception(); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { return recv_truthify(returnState); }); } folly::SemiFuture> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::semifuture_truthify() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_truthify(rpcOptions); } folly::SemiFuture> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::semifuture_truthify(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_truthify, channel_); auto callback = std::move(callbackAndFuture.first); truthify(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::recv_wrapped_truthify(apache::thrift::ClientBufferedStream& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = ::cpp2::InteractWithShared_MyInteraction_truthify_presult; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } apache::thrift::ClientBufferedStream apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::recv_truthify(::apache::thrift::ClientReceiveState& state) { apache::thrift::ClientBufferedStream _return; auto ew = recv_wrapped_truthify(_return, state); if (ew) { ew.throw_exception(); } return _return; } void apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::fbthrift_serialize_and_send_encode(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback, bool stealRpcOptions) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_encode(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_encode(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_encode(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::encodeCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.MyInteraction.encode", *header); return {std::move(ctx), std::move(header)}; } #if FOLLY_HAS_COROUTINES folly::coro::Task, ::std::string, ::std::string>> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::co_encode() { ::apache::thrift::RpcOptions rpcOptions; co_return co_await co_encode(rpcOptions); } folly::coro::Task, ::std::string, ::std::string>> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::co_encode(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] = encodeCtx(&rpcOptions); using CancellableCallback = apache::thrift::CancellableRequestClientCallback; auto cancellableCallback = cancellable ? CancellableCallback::create(&callback, channel_) : nullptr; auto wrappedCallback = apache::thrift::createSinkClientCallback( apache::thrift::RequestClientCallback::Ptr(apache::thrift::RequestClientCallback::Ptr(cancellableCallback ? (apache::thrift::RequestClientCallback*)cancellableCallback.get() : &callback))); fbthrift_serialize_and_send_encode(rpcOptions, std::move(header), ctx.get(), 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)); co_return recv_encode(returnState); } #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::recv_wrapped_encode(apache::thrift::ResponseAndClientSink<::std::set<::std::int32_t>, ::std::string, ::std::string>& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = ::cpp2::InteractWithShared_MyInteraction_encode_presult; using ExMapType = apache::thrift::detail::ap::EmptyExMapType; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, state.extractSink(), _return); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, state.extractSink(), _return); } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } apache::thrift::ResponseAndClientSink<::std::set<::std::int32_t>, ::std::string, ::std::string> apache::thrift::Client<::cpp2::InteractWithShared>::MyInteraction::recv_encode(::apache::thrift::ClientReceiveState& state) { apache::thrift::ResponseAndClientSink<::std::set<::std::int32_t>, ::std::string, ::std::string> _return; auto ew = recv_wrapped_encode(_return, state); if (ew) { ew.throw_exception(); } return _return; } namespace thrift::shared_interactions { typedef apache::thrift::ThriftPresult InteractWithShared_SharedInteraction_init_pargs; typedef apache::thrift::ThriftPresult> InteractWithShared_SharedInteraction_init_presult; typedef apache::thrift::ThriftPresult InteractWithShared_SharedInteraction_do_something_pargs; typedef apache::thrift::ThriftPresult> InteractWithShared_SharedInteraction_do_something_presult; typedef apache::thrift::ThriftPresult InteractWithShared_SharedInteraction_tear_down_pargs; typedef apache::thrift::ThriftPresult InteractWithShared_SharedInteraction_tear_down_presult; } // namespace thrift::shared_interactions template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::fbthrift_serialize_init(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::thrift::shared_interactions::InteractWithShared_SharedInteraction_init_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "SharedInteraction.init", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::fbthrift_send_init(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "SharedInteraction.init", ::apache::thrift::FunctionQualifier::Unspecified, "InteractWithShared", ::apache::thrift::InteractionMethodPosition::Member, "SharedInteraction"); apache::thrift::clientSendT(std::move(request), std::move(rpcOpts), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::fbthrift_serialize_do_something(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::thrift::shared_interactions::InteractWithShared_SharedInteraction_do_something_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "SharedInteraction.do_something", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::fbthrift_send_do_something(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "SharedInteraction.do_something", ::apache::thrift::FunctionQualifier::Unspecified, "InteractWithShared", ::apache::thrift::InteractionMethodPosition::Member, "SharedInteraction"); apache::thrift::clientSendT(std::move(request), std::move(rpcOpts), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } template apache::thrift::SerializedRequest apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::fbthrift_serialize_tear_down(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::thrift::shared_interactions::InteractWithShared_SharedInteraction_tear_down_pargs args; const auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; const auto writer = [&](Protocol_* p) { args.write(p); }; return apache::thrift::preprocessSendT( prot, rpcOptions, contextStack, header, "SharedInteraction.tear_down", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::fbthrift_send_tear_down(apache::thrift::SerializedRequest&& request, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "SharedInteraction.tear_down", ::apache::thrift::FunctionQualifier::Unspecified, "InteractWithShared", ::apache::thrift::InteractionMethodPosition::Member, "SharedInteraction"); apache::thrift::clientSendT(std::move(request), std::move(rpcOpts), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::init(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = initCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_init(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::fbthrift_serialize_and_send_init(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_init(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_init(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_init(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::initCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.SharedInteraction.init", *header); return {std::move(ctx), std::move(header)}; } ::std::int32_t apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::sync_init() { ::apache::thrift::RpcOptions rpcOptions; return sync_init(rpcOptions); } ::std::int32_t apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::sync_init(apache::thrift::RpcOptions& rpcOptions) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = initCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); #if FOLLY_HAS_COROUTINES const bool shouldProcessClientInterceptors = ctxAndHeader.first && ctxAndHeader.first->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnRequest()); } #endif callback.waitUntilDone( evb, [&] { fbthrift_serialize_and_send_init(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); #if FOLLY_HAS_COROUTINES if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnResponse()); } #endif if (returnState.isException()) { returnState.exception().throw_exception(); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { return recv_init(returnState); }); } folly::SemiFuture<::std::int32_t> apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::semifuture_init() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_init(rpcOptions); } folly::SemiFuture<::std::int32_t> apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::semifuture_init(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_init, channel_); auto callback = std::move(callbackAndFuture.first); init(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::recv_wrapped_init(::std::int32_t& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = ::thrift::shared_interactions::InteractWithShared_SharedInteraction_init_presult; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } ::std::int32_t apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::recv_init(::apache::thrift::ClientReceiveState& state) { ::std::int32_t _return; auto ew = recv_wrapped_init(_return, state); if (ew) { ew.throw_exception(); } return _return; } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::do_something(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = do_somethingCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_do_something(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::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) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_do_something(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_do_something(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_do_something(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::do_somethingCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.SharedInteraction.do_something", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::sync_do_something(::thrift::shared_interactions::DoSomethingResult& _return) { ::apache::thrift::RpcOptions rpcOptions; sync_do_something(rpcOptions, _return); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::sync_do_something(apache::thrift::RpcOptions& rpcOptions, ::thrift::shared_interactions::DoSomethingResult& _return) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = do_somethingCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); #if FOLLY_HAS_COROUTINES const bool shouldProcessClientInterceptors = ctxAndHeader.first && ctxAndHeader.first->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnRequest()); } #endif callback.waitUntilDone( evb, [&] { fbthrift_serialize_and_send_do_something(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); #if FOLLY_HAS_COROUTINES if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnResponse()); } #endif if (returnState.isException()) { returnState.exception().throw_exception(); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { recv_do_something(_return, returnState); }); } folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::semifuture_do_something() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_do_something(rpcOptions); } folly::SemiFuture<::thrift::shared_interactions::DoSomethingResult> apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::semifuture_do_something(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_do_something, channel_); auto callback = std::move(callbackAndFuture.first); do_something(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::recv_wrapped_do_something(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = ::thrift::shared_interactions::InteractWithShared_SharedInteraction_do_something_presult; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state, _return); } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::recv_do_something(::thrift::shared_interactions::DoSomethingResult& _return, ::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_do_something(_return, state); if (ew) { ew.throw_exception(); } } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::tear_down(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = tear_downCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_tear_down(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::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) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_tear_down(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_tear_down(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_tear_down(std::move(request), rpcOptions, std::move(header), std::move(callback)); } }); } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::tear_downCtx(apache::thrift::RpcOptions* rpcOptions) { auto header = std::make_shared( apache::thrift::transport::THeader::ALLOW_BIG_FRAMES); header->setProtocolId(channel_->getProtocolId()); if (rpcOptions) { header->setHeaders(rpcOptions->releaseWriteHeaders()); } auto ctx = apache::thrift::ContextStack::createWithClientContext( handlers_, interceptors_, getServiceName(), "InteractWithShared.SharedInteraction.tear_down", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::sync_tear_down() { ::apache::thrift::RpcOptions rpcOptions; sync_tear_down(rpcOptions); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::sync_tear_down(apache::thrift::RpcOptions& rpcOptions) { apache::thrift::ClientReceiveState returnState; apache::thrift::ClientSyncCallback callback(&returnState); auto protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto evb = apache::thrift::GeneratedAsyncClient::getChannel()->getEventBase(); auto ctxAndHeader = tear_downCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); #if FOLLY_HAS_COROUTINES const bool shouldProcessClientInterceptors = ctxAndHeader.first && ctxAndHeader.first->shouldProcessClientInterceptors(); if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnRequest()); } #endif callback.waitUntilDone( evb, [&] { fbthrift_serialize_and_send_tear_down(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); #if FOLLY_HAS_COROUTINES if (shouldProcessClientInterceptors) { folly::coro::blockingWait(ctxAndHeader.first->processClientInterceptorsOnResponse()); } #endif if (returnState.isException()) { returnState.exception().throw_exception(); } returnState.resetProtocolId(protocolId); returnState.resetCtx(std::move(ctxAndHeader.first)); SCOPE_EXIT { if (returnState.header() && !returnState.header()->getHeaders().empty()) { rpcOptions.setReadHeaders(returnState.header()->releaseHeaders()); } }; return folly::fibers::runInMainContext([&] { recv_tear_down(returnState); }); } folly::SemiFuture apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::semifuture_tear_down() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_tear_down(rpcOptions); } folly::SemiFuture apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::semifuture_tear_down(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_tear_down, channel_); auto callback = std::move(callbackAndFuture.first); tear_down(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::recv_wrapped_tear_down(::apache::thrift::ClientReceiveState& state) { if (state.isException()) { return std::move(state.exception()); } if (!state.hasResponseBuffer()) { return folly::make_exception_wrapper("recv_ called without result"); } using result = ::thrift::shared_interactions::InteractWithShared_SharedInteraction_tear_down_presult; switch (state.protocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state); } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolReader reader; return apache::thrift::detail::ac::recv_wrapped( &reader, state); } default: { } } return folly::make_exception_wrapper("Could not find Protocol"); } void apache::thrift::Client<::cpp2::InteractWithShared>::SharedInteraction::recv_tear_down(::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_tear_down(state); if (ew) { ew.throw_exception(); } }