/** * 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/MyServiceAsyncClient.h" #include namespace cpp2 { typedef apache::thrift::ThriftPresult MyService_foo_pargs; typedef apache::thrift::ThriftPresult MyService_foo_presult; typedef apache::thrift::ThriftPresult> MyService_interact_pargs; typedef apache::thrift::ThriftPresult MyService_interact_presult; typedef apache::thrift::ThriftPresult MyService_interactFast_pargs; typedef apache::thrift::ThriftPresult> MyService_interactFast_presult; typedef apache::thrift::ThriftPresult MyService_serialize_pargs; typedef apache::thrift::ThriftPResultStream< apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > MyService_serialize_presult; } // namespace cpp2 template void apache::thrift::Client<::cpp2::MyService>::fooT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { ::cpp2::MyService_foo_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "foo", ::apache::thrift::FunctionQualifier::Unspecified, "MyService"); apache::thrift::clientSendT(prot, std::forward(rpcOptions), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::interactT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle, ::std::int32_t p_arg) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(handle, rpcOpts); ::cpp2::MyService_interact_pargs args; args.get<0>().value = &p_arg; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "interact", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Factory, "MyInteraction"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::interactFastT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(handle, rpcOpts); ::cpp2::MyService_interactFast_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "interactFast", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Factory, "MyInteractionFast"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::serializeT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, const apache::thrift::InteractionHandle& handle) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(handle, rpcOpts); ::cpp2::MyService_serialize_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "serialize", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Factory, "SerialInteraction"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } apache::thrift::Client<::cpp2::MyService>::MyInteraction apache::thrift::Client<::cpp2::MyService>::createMyInteraction() { return MyInteraction(channel_, "MyInteraction"); } apache::thrift::Client<::cpp2::MyService>::MyInteractionFast apache::thrift::Client<::cpp2::MyService>::createMyInteractionFast() { return MyInteractionFast(channel_, "MyInteractionFast"); } apache::thrift::Client<::cpp2::MyService>::SerialInteraction apache::thrift::Client<::cpp2::MyService>::createSerialInteraction() { return SerialInteraction(channel_, "SerialInteraction"); } void apache::thrift::Client<::cpp2::MyService>::foo(std::unique_ptr callback) { ::apache::thrift::RpcOptions rpcOptions; foo(rpcOptions, std::move(callback)); } void apache::thrift::Client<::cpp2::MyService>::foo(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = fooCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); fooImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::fooImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { fooT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { fooT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { fooT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { fooT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::fooCtx(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_, getServiceName(), "MyService.foo", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::MyService>::sync_foo() { ::apache::thrift::RpcOptions rpcOptions; sync_foo(rpcOptions); } void apache::thrift::Client<::cpp2::MyService>::sync_foo(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 = fooCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); callback.waitUntilDone( evb, [&] { fooImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); 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_foo(returnState); }); } folly::Future apache::thrift::Client<::cpp2::MyService>::future_foo() { ::apache::thrift::RpcOptions rpcOptions; return future_foo(rpcOptions); } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::semifuture_foo() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_foo(rpcOptions); } folly::Future apache::thrift::Client<::cpp2::MyService>::future_foo(apache::thrift::RpcOptions& rpcOptions) { folly::Promise promise; auto future = promise.getFuture(); auto callback = std::make_unique>(std::move(promise), recv_wrapped_foo, channel_); foo(rpcOptions, std::move(callback)); return future; } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::semifuture_foo(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_foo, channel_); auto callback = std::move(callbackAndFuture.first); foo(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } folly::Future>> apache::thrift::Client<::cpp2::MyService>::header_future_foo(apache::thrift::RpcOptions& rpcOptions) { folly::Promise>> promise; auto future = promise.getFuture(); auto callback = std::make_unique>(std::move(promise), recv_wrapped_foo, channel_); foo(rpcOptions, std::move(callback)); return future; } folly::SemiFuture>> apache::thrift::Client<::cpp2::MyService>::header_semifuture_foo(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeHeaderSemiFutureCallback(recv_wrapped_foo, channel_); auto callback = std::move(callbackAndFuture.first); foo(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } void apache::thrift::Client<::cpp2::MyService>::foo(folly::Function callback) { foo(std::make_unique(std::move(callback))); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::MyService>::recv_wrapped_foo(::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::MyService_foo_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::MyService>::recv_foo(::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_foo(state); if (ew) { ew.throw_exception(); } } void apache::thrift::Client<::cpp2::MyService>::recv_instance_foo(::apache::thrift::ClientReceiveState& state) { recv_foo(state); } folly::exception_wrapper apache::thrift::Client<::cpp2::MyService>::recv_instance_wrapped_foo(::apache::thrift::ClientReceiveState& state) { return recv_wrapped_foo(state); } void apache::thrift::Client<::cpp2::MyService>::interact(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const apache::thrift::InteractionHandle& handle, ::std::int32_t p_arg) { auto [ctx, header] = interactCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); interactImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback), handle, p_arg); } void apache::thrift::Client<::cpp2::MyService>::interactImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle, ::std::int32_t p_arg, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { interactT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback), handle, p_arg); } else { interactT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback), handle, p_arg); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { interactT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback), handle, p_arg); } else { interactT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback), handle, p_arg); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::interactCtx(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_, getServiceName(), "MyService.interact", *header); return {std::move(ctx), std::move(header)}; } apache::thrift::Client<::cpp2::MyService>::MyInteraction apache::thrift::Client<::cpp2::MyService>::sync_interact(::std::int32_t p_arg) { ::apache::thrift::RpcOptions rpcOptions; return sync_interact(rpcOptions, p_arg); } apache::thrift::Client<::cpp2::MyService>::MyInteraction apache::thrift::Client<::cpp2::MyService>::sync_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg) { 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 = interactCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); MyInteraction handle(channel_, "MyInteraction"); callback.waitUntilDone( evb, [&] { interactImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback), handle, p_arg); }); 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_interact(returnState); return std::move(handle); }); } folly::SemiFuture::MyInteraction> apache::thrift::Client<::cpp2::MyService>::semifuture_interact(::std::int32_t p_arg) { ::apache::thrift::RpcOptions rpcOptions; return semifuture_interact(rpcOptions, p_arg); } folly::SemiFuture::MyInteraction> apache::thrift::Client<::cpp2::MyService>::semifuture_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_interact, channel_); MyInteraction handle(channel_, "MyInteraction"); auto callback = std::move(callbackAndFuture.first); interact(rpcOptions, std::move(callback), handle, p_arg); return std::move(callbackAndFuture.second).deferValue([handle = std::move(handle)](auto&&) mutable { return std::move(handle); }); } std::pair< apache::thrift::Client<::cpp2::MyService>::MyInteraction, folly::SemiFuture > apache::thrift::Client<::cpp2::MyService>::eager_semifuture_interact(apache::thrift::RpcOptions& rpcOptions, ::std::int32_t p_arg) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_interact, channel_); MyInteraction handle(channel_, "MyInteraction"); auto callback = std::move(callbackAndFuture.first); interact(rpcOptions, std::move(callback), handle, p_arg); return std::make_pair(std::move(handle), std::move(callbackAndFuture.second)); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::MyService>::recv_wrapped_interact(::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::MyService_interact_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::MyService>::recv_interact(::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_interact(state); if (ew) { ew.throw_exception(); } } void apache::thrift::Client<::cpp2::MyService>::interactFast(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const apache::thrift::InteractionHandle& handle) { auto [ctx, header] = interactFastCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); interactFastImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback), handle); } void apache::thrift::Client<::cpp2::MyService>::interactFastImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const apache::thrift::InteractionHandle& handle, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { interactFastT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback), handle); } else { interactFastT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback), handle); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { interactFastT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback), handle); } else { interactFastT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback), handle); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::interactFastCtx(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_, getServiceName(), "MyService.interactFast", *header); return {std::move(ctx), std::move(header)}; } std::pair::MyInteractionFast, ::std::int32_t> apache::thrift::Client<::cpp2::MyService>::sync_interactFast() { ::apache::thrift::RpcOptions rpcOptions; return sync_interactFast(rpcOptions); } std::pair::MyInteractionFast, ::std::int32_t> apache::thrift::Client<::cpp2::MyService>::sync_interactFast(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 = interactFastCtx(&rpcOptions); auto wrappedCallback = apache::thrift::RequestClientCallback::Ptr(&callback); MyInteractionFast handle(channel_, "MyInteractionFast"); callback.waitUntilDone( evb, [&] { interactFastImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback), handle); }); 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 std::make_pair( std::move(handle), recv_interactFast(returnState) ); }); } folly::SemiFuture::MyInteractionFast, ::std::int32_t>> apache::thrift::Client<::cpp2::MyService>::semifuture_interactFast() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_interactFast(rpcOptions); } folly::SemiFuture::MyInteractionFast, ::std::int32_t>> apache::thrift::Client<::cpp2::MyService>::semifuture_interactFast(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_interactFast, channel_); MyInteractionFast handle(channel_, "MyInteractionFast"); auto callback = std::move(callbackAndFuture.first); interactFast(rpcOptions, std::move(callback), handle); return std::move(callbackAndFuture.second).deferValue([handle = std::move(handle)](auto&& val) mutable { return std::make_pair(std::move(handle), std::move(val)); }); } std::pair< apache::thrift::Client<::cpp2::MyService>::MyInteractionFast, folly::SemiFuture<::std::int32_t> > apache::thrift::Client<::cpp2::MyService>::eager_semifuture_interactFast(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_interactFast, channel_); MyInteractionFast handle(channel_, "MyInteractionFast"); auto callback = std::move(callbackAndFuture.first); interactFast(rpcOptions, std::move(callback), handle); return std::make_pair(std::move(handle), std::move(callbackAndFuture.second)); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::MyService>::recv_wrapped_interactFast(::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::MyService_interactFast_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::MyService>::recv_interactFast(::apache::thrift::ClientReceiveState& state) { ::std::int32_t _return; auto ew = recv_wrapped_interactFast(_return, state); if (ew) { ew.throw_exception(); } return _return; } void apache::thrift::Client<::cpp2::MyService>::serialize(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const apache::thrift::InteractionHandle& handle) { auto [ctx, header] = serializeCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)), rpcOptions.getBufferOptions()); serializeImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback), handle); } void apache::thrift::Client<::cpp2::MyService>::serializeImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, const apache::thrift::InteractionHandle& handle, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { serializeT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback), handle); } else { serializeT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback), handle); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { serializeT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback), handle); } else { serializeT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback), handle); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::serializeCtx(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_, getServiceName(), "MyService.serialize", *header); return {std::move(ctx), std::move(header)}; } std::pair::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>> apache::thrift::Client<::cpp2::MyService>::sync_serialize() { ::apache::thrift::RpcOptions rpcOptions; return sync_serialize(rpcOptions); } std::pair::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>> apache::thrift::Client<::cpp2::MyService>::sync_serialize(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 = serializeCtx(&rpcOptions); auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::RequestClientCallback::Ptr(&callback), rpcOptions.getBufferOptions()); SerialInteraction handle(channel_, "SerialInteraction"); callback.waitUntilDone( evb, [&] { serializeImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback), handle); }); 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 std::make_pair( std::move(handle), recv_serialize(returnState) ); }); } folly::SemiFuture::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> apache::thrift::Client<::cpp2::MyService>::semifuture_serialize() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_serialize(rpcOptions); } folly::SemiFuture::SerialInteraction, apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t>>> apache::thrift::Client<::cpp2::MyService>::semifuture_serialize(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_serialize, channel_); SerialInteraction handle(channel_, "SerialInteraction"); auto callback = std::move(callbackAndFuture.first); serialize(rpcOptions, std::move(callback), handle); return std::move(callbackAndFuture.second).deferValue([handle = std::move(handle)](auto&& val) mutable { return std::make_pair(std::move(handle), std::move(val)); }); } std::pair< apache::thrift::Client<::cpp2::MyService>::SerialInteraction, folly::SemiFuture> > apache::thrift::Client<::cpp2::MyService>::eager_semifuture_serialize(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_serialize, channel_); SerialInteraction handle(channel_, "SerialInteraction"); auto callback = std::move(callbackAndFuture.first); serialize(rpcOptions, std::move(callback), handle); return std::make_pair(std::move(handle), std::move(callbackAndFuture.second)); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::cpp2::MyService>::recv_wrapped_serialize(apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::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::MyService_serialize_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::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t> apache::thrift::Client<::cpp2::MyService>::recv_serialize(::apache::thrift::ClientReceiveState& state) { apache::thrift::ResponseAndClientBufferedStream<::std::int32_t,::std::int32_t> _return; auto ew = recv_wrapped_serialize(_return, state); if (ew) { ew.throw_exception(); } return _return; } namespace cpp2 { typedef apache::thrift::ThriftPresult MyService_MyInteraction_frobnicate_pargs; typedef apache::thrift::ThriftPresult, apache::thrift::FieldData<1, ::apache::thrift::type_class::structure, ::cpp2::CustomException>> MyService_MyInteraction_frobnicate_presult; typedef apache::thrift::ThriftPresult MyService_MyInteraction_ping_pargs; typedef apache::thrift::ThriftPresult MyService_MyInteraction_truthify_pargs; typedef apache::thrift::ThriftPResultStream< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult> > MyService_MyInteraction_truthify_presult; typedef apache::thrift::ThriftPresult MyService_MyInteraction_encode_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, ::std::set<::std::int32_t>*>>, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > MyService_MyInteraction_encode_presult; } // namespace cpp2 template void apache::thrift::Client<::cpp2::MyService>::MyInteraction::frobnicateT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteraction_frobnicate_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.frobnicate", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::MyInteraction::pingT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteraction_ping_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.ping", ::apache::thrift::FunctionQualifier::OneWay, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::MyInteraction::truthifyT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteraction_truthify_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.truthify", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::MyInteraction::encodeT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteraction_encode_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteraction.encode", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteraction"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } void apache::thrift::Client<::cpp2::MyService>::MyInteraction::frobnicate(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = frobnicateCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); frobnicateImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::MyInteraction::frobnicateImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { frobnicateT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { frobnicateT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { frobnicateT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { frobnicateT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::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_, getServiceName(), "MyService.MyInteraction.frobnicate", *header); return {std::move(ctx), std::move(header)}; } ::std::int32_t apache::thrift::Client<::cpp2::MyService>::MyInteraction::sync_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; return sync_frobnicate(rpcOptions); } ::std::int32_t apache::thrift::Client<::cpp2::MyService>::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); callback.waitUntilDone( evb, [&] { frobnicateImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); 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::MyService>::MyInteraction::semifuture_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_frobnicate(rpcOptions); } folly::SemiFuture<::std::int32_t> apache::thrift::Client<::cpp2::MyService>::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::MyService>::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::MyService_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::MyService>::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::MyService>::MyInteraction::ping(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = pingCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.oneWay = true; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); pingImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::MyInteraction::pingImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { pingT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { pingT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { pingT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { pingT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::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_, getServiceName(), "MyService.MyInteraction.ping", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::MyService>::MyInteraction::sync_ping() { ::apache::thrift::RpcOptions rpcOptions; sync_ping(rpcOptions); } void apache::thrift::Client<::cpp2::MyService>::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); callback.waitUntilDone( evb, [&] { pingImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); if (returnState.isException()) { returnState.exception().throw_exception(); } } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::MyInteraction::semifuture_ping() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_ping(rpcOptions); } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::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::MyService>::MyInteraction::truthify(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = truthifyCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)), rpcOptions.getBufferOptions()); truthifyImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::MyInteraction::truthifyImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { truthifyT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { truthifyT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { truthifyT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { truthifyT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::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_, getServiceName(), "MyService.MyInteraction.truthify", *header); return {std::move(ctx), std::move(header)}; } apache::thrift::ClientBufferedStream apache::thrift::Client<::cpp2::MyService>::MyInteraction::sync_truthify() { ::apache::thrift::RpcOptions rpcOptions; return sync_truthify(rpcOptions); } apache::thrift::ClientBufferedStream apache::thrift::Client<::cpp2::MyService>::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()); callback.waitUntilDone( evb, [&] { truthifyImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); 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::MyService>::MyInteraction::semifuture_truthify() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_truthify(rpcOptions); } folly::SemiFuture> apache::thrift::Client<::cpp2::MyService>::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::MyService>::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::MyService_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::MyService>::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::MyService>::MyInteraction::encodeImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { encodeT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { encodeT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { encodeT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { encodeT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::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_, getServiceName(), "MyService.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::MyService>::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::MyService>::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))); encodeImpl(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::MyService>::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::MyService_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::MyService>::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 cpp2 { typedef apache::thrift::ThriftPresult MyService_MyInteractionFast_frobnicate_pargs; typedef apache::thrift::ThriftPresult> MyService_MyInteractionFast_frobnicate_presult; typedef apache::thrift::ThriftPresult MyService_MyInteractionFast_ping_pargs; typedef apache::thrift::ThriftPresult MyService_MyInteractionFast_truthify_pargs; typedef apache::thrift::ThriftPResultStream< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult> > MyService_MyInteractionFast_truthify_presult; typedef apache::thrift::ThriftPresult MyService_MyInteractionFast_encode_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, ::std::set<::std::int32_t>*>>, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > MyService_MyInteractionFast_encode_presult; } // namespace cpp2 template void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::frobnicateT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteractionFast_frobnicate_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteractionFast.frobnicate", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteractionFast"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::pingT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteractionFast_ping_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteractionFast.ping", ::apache::thrift::FunctionQualifier::OneWay, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteractionFast"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::truthifyT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteractionFast_truthify_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteractionFast.truthify", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteractionFast"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } template void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::encodeT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_MyInteractionFast_encode_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "MyInteractionFast.encode", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "MyInteractionFast"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::frobnicate(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = frobnicateCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); frobnicateImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::frobnicateImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { frobnicateT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { frobnicateT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { frobnicateT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { frobnicateT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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_, getServiceName(), "MyService.MyInteractionFast.frobnicate", *header); return {std::move(ctx), std::move(header)}; } ::std::int32_t apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::sync_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; return sync_frobnicate(rpcOptions); } ::std::int32_t apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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); callback.waitUntilDone( evb, [&] { frobnicateImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); 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::MyService>::MyInteractionFast::semifuture_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_frobnicate(rpcOptions); } folly::SemiFuture<::std::int32_t> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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::MyService>::MyInteractionFast::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::MyService_MyInteractionFast_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::MyService>::MyInteractionFast::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::MyService>::MyInteractionFast::ping(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = pingCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.oneWay = true; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); pingImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::pingImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { pingT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { pingT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { pingT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { pingT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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_, getServiceName(), "MyService.MyInteractionFast.ping", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::sync_ping() { ::apache::thrift::RpcOptions rpcOptions; sync_ping(rpcOptions); } void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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); callback.waitUntilDone( evb, [&] { pingImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); if (returnState.isException()) { returnState.exception().throw_exception(); } } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::semifuture_ping() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_ping(rpcOptions); } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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::MyService>::MyInteractionFast::truthify(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = truthifyCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::createStreamClientCallback( apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)), rpcOptions.getBufferOptions()); truthifyImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::truthifyImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::StreamClientCallback* callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { truthifyT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { truthifyT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { truthifyT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { truthifyT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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_, getServiceName(), "MyService.MyInteractionFast.truthify", *header); return {std::move(ctx), std::move(header)}; } apache::thrift::ClientBufferedStream apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::sync_truthify() { ::apache::thrift::RpcOptions rpcOptions; return sync_truthify(rpcOptions); } apache::thrift::ClientBufferedStream apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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()); callback.waitUntilDone( evb, [&] { truthifyImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); 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::MyService>::MyInteractionFast::semifuture_truthify() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_truthify(rpcOptions); } folly::SemiFuture> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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::MyService>::MyInteractionFast::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::MyService_MyInteractionFast_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::MyService>::MyInteractionFast::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::MyService>::MyInteractionFast::encodeImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::SinkClientCallback* callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { encodeT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { encodeT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { encodeT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { encodeT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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_, getServiceName(), "MyService.MyInteractionFast.encode", *header); return {std::move(ctx), std::move(header)}; } #if FOLLY_HAS_COROUTINES folly::coro::Task, ::std::string, ::std::string>> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::co_encode() { ::apache::thrift::RpcOptions rpcOptions; co_return co_await co_encode(rpcOptions); } folly::coro::Task, ::std::string, ::std::string>> apache::thrift::Client<::cpp2::MyService>::MyInteractionFast::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))); encodeImpl(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::MyService>::MyInteractionFast::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::MyService_MyInteractionFast_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::MyService>::MyInteractionFast::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 cpp2 { typedef apache::thrift::ThriftPresult MyService_SerialInteraction_frobnicate_pargs; typedef apache::thrift::ThriftPresult MyService_SerialInteraction_frobnicate_presult; } // namespace cpp2 template void apache::thrift::Client<::cpp2::MyService>::SerialInteraction::frobnicateT(Protocol_* prot, RpcOptions&& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback) { apache::thrift::RpcOptions rpcOpts(std::forward(rpcOptions)); setInteraction(rpcOpts); ::cpp2::MyService_SerialInteraction_frobnicate_pargs args; auto sizer = [&](Protocol_* p) { return args.serializedSizeZC(p); }; auto writer = [&](Protocol_* p) { args.write(p); }; static ::apache::thrift::MethodMetadata::Data* methodMetadata = new ::apache::thrift::MethodMetadata::Data( "SerialInteraction.frobnicate", ::apache::thrift::FunctionQualifier::Unspecified, "MyService", ::apache::thrift::InteractionMethodPosition::Member, "SerialInteraction"); apache::thrift::clientSendT(prot, std::move(rpcOpts), std::move(callback), contextStack, std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata), writer, sizer); } void apache::thrift::Client<::cpp2::MyService>::SerialInteraction::frobnicate(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = frobnicateCtx(&rpcOptions); apache::thrift::RequestCallback::Context callbackContext; callbackContext.protocolId = apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(); auto* contextStack = ctx.get(); if (callback) { callbackContext.ctx = std::move(ctx); } auto wrappedCallback = apache::thrift::toRequestClientCallbackPtr(std::move(callback), std::move(callbackContext)); frobnicateImpl(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::cpp2::MyService>::SerialInteraction::frobnicateImpl(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, bool stealRpcOptions) { switch (apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId()) { case apache::thrift::protocol::T_BINARY_PROTOCOL: { apache::thrift::BinaryProtocolWriter writer; if (stealRpcOptions) { frobnicateT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { frobnicateT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } case apache::thrift::protocol::T_COMPACT_PROTOCOL: { apache::thrift::CompactProtocolWriter writer; if (stealRpcOptions) { frobnicateT(&writer, std::move(rpcOptions), std::move(header), contextStack, std::move(callback)); } else { frobnicateT(&writer, rpcOptions, std::move(header), contextStack, std::move(callback)); } break; } default: { apache::thrift::detail::ac::throw_app_exn("Could not find Protocol"); } } } std::pair<::apache::thrift::ContextStack::UniquePtr, std::shared_ptr<::apache::thrift::transport::THeader>> apache::thrift::Client<::cpp2::MyService>::SerialInteraction::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_, getServiceName(), "MyService.SerialInteraction.frobnicate", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::cpp2::MyService>::SerialInteraction::sync_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; sync_frobnicate(rpcOptions); } void apache::thrift::Client<::cpp2::MyService>::SerialInteraction::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); callback.waitUntilDone( evb, [&] { frobnicateImpl(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback)); }); 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_frobnicate(returnState); }); } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::SerialInteraction::semifuture_frobnicate() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_frobnicate(rpcOptions); } folly::SemiFuture apache::thrift::Client<::cpp2::MyService>::SerialInteraction::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::MyService>::SerialInteraction::recv_wrapped_frobnicate(::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::MyService_SerialInteraction_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); } 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::MyService>::SerialInteraction::recv_frobnicate(::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_frobnicate(state); if (ew) { ew.throw_exception(); } }