/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/adapter/src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #include "thrift/compiler/test/fixtures/adapter/gen-cpp2/AdapterServiceAsyncClient.h" #include namespace facebook::thrift::test { typedef apache::thrift::ThriftPresult AdapterService_count_pargs; typedef apache::thrift::ThriftPresult> AdapterService_count_presult; typedef apache::thrift::ThriftPresult>>> AdapterService_adaptedTypes_pargs; typedef apache::thrift::ThriftPresult>>> AdapterService_adaptedTypes_presult; } // namespace facebook::thrift::test template apache::thrift::SerializedRequest apache::thrift::Client<::facebook::thrift::test::AdapterService>::fbthrift_serialize_count(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack) { ::facebook::thrift::test::AdapterService_count_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, "count", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::facebook::thrift::test::AdapterService>::fbthrift_send_count(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( "count", ::apache::thrift::FunctionQualifier::Unspecified, "facebook.com/thrift/test/AdapterService"); apache::thrift::clientSendT(std::move(request), std::forward(rpcOptions), std::move(callback), std::move(header), channel_.get(), ::apache::thrift::MethodMetadata::from_static(methodMetadata)); } template apache::thrift::SerializedRequest apache::thrift::Client<::facebook::thrift::test::AdapterService>::fbthrift_serialize_adaptedTypes(Protocol_* prot, const RpcOptions& rpcOptions, apache::thrift::transport::THeader& header, apache::thrift::ContextStack* contextStack, const ::facebook::thrift::test::HeapAllocated& p_arg) { ::facebook::thrift::test::AdapterService_adaptedTypes_pargs args; args.get<0>().value = const_cast<::facebook::thrift::test::HeapAllocated*>(&p_arg); 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, "adaptedTypes", writer, sizer, channel_->getChecksumSamplingRate()); } template void apache::thrift::Client<::facebook::thrift::test::AdapterService>::fbthrift_send_adaptedTypes(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( "adaptedTypes", ::apache::thrift::FunctionQualifier::Unspecified, "facebook.com/thrift/test/AdapterService"); 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<::facebook::thrift::test::AdapterService>::count(std::unique_ptr callback) { ::apache::thrift::RpcOptions rpcOptions; count(rpcOptions, std::move(callback)); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::count(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback) { auto [ctx, header] = countCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_count(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback)); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::fbthrift_serialize_and_send_count(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_count(&writer, rpcOptions, *header, contextStack); if (stealRpcOptions) { fbthrift_send_count(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_count(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<::facebook::thrift::test::AdapterService>::countCtx(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(), "AdapterService.count", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::sync_count(::facebook::thrift::test::CountingStruct& _return) { ::apache::thrift::RpcOptions rpcOptions; sync_count(rpcOptions, _return); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::sync_count(apache::thrift::RpcOptions& rpcOptions, ::facebook::thrift::test::CountingStruct& _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 = countCtx(&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_count(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_count(_return, returnState); }); } folly::Future<::facebook::thrift::test::CountingStruct> apache::thrift::Client<::facebook::thrift::test::AdapterService>::future_count() { ::apache::thrift::RpcOptions rpcOptions; return future_count(rpcOptions); } folly::SemiFuture<::facebook::thrift::test::CountingStruct> apache::thrift::Client<::facebook::thrift::test::AdapterService>::semifuture_count() { ::apache::thrift::RpcOptions rpcOptions; return semifuture_count(rpcOptions); } folly::Future<::facebook::thrift::test::CountingStruct> apache::thrift::Client<::facebook::thrift::test::AdapterService>::future_count(apache::thrift::RpcOptions& rpcOptions) { using CallbackHelper = apache::thrift::detail::FutureCallbackHelper<::facebook::thrift::test::CountingStruct>; folly::Promise promise; auto future = promise.getFuture(); auto callback = std::make_unique>(std::move(promise), recv_wrapped_count, channel_); count(rpcOptions, std::move(callback)); return std::move(future).thenValue(CallbackHelper::extractResult); } folly::SemiFuture<::facebook::thrift::test::CountingStruct> apache::thrift::Client<::facebook::thrift::test::AdapterService>::semifuture_count(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_count, channel_); auto callback = std::move(callbackAndFuture.first); count(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } folly::Future>> apache::thrift::Client<::facebook::thrift::test::AdapterService>::header_future_count(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_count, channel_); count(rpcOptions, std::move(callback)); return std::move(future).thenValue(CallbackHelper::extractResult); } folly::SemiFuture>> apache::thrift::Client<::facebook::thrift::test::AdapterService>::header_semifuture_count(apache::thrift::RpcOptions& rpcOptions) { auto callbackAndFuture = makeHeaderSemiFutureCallback(recv_wrapped_count, channel_); auto callback = std::move(callbackAndFuture.first); count(rpcOptions, std::move(callback)); return std::move(callbackAndFuture.second); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::count(folly::Function callback) { count(std::make_unique(std::move(callback))); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::facebook::thrift::test::AdapterService>::recv_wrapped_count(::facebook::thrift::test::CountingStruct& _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 = ::facebook::thrift::test::AdapterService_count_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<::facebook::thrift::test::AdapterService>::recv_count(::facebook::thrift::test::CountingStruct& _return, ::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_count(_return, state); if (ew) { ew.throw_exception(); } } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::recv_instance_count(::facebook::thrift::test::CountingStruct& _return, ::apache::thrift::ClientReceiveState& state) { return recv_count(_return, state); } folly::exception_wrapper apache::thrift::Client<::facebook::thrift::test::AdapterService>::recv_instance_wrapped_count(::facebook::thrift::test::CountingStruct& _return, ::apache::thrift::ClientReceiveState& state) { return recv_wrapped_count(_return, state); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::adaptedTypes(std::unique_ptr callback, const ::facebook::thrift::test::HeapAllocated& p_arg) { ::apache::thrift::RpcOptions rpcOptions; adaptedTypes(rpcOptions, std::move(callback), p_arg); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::adaptedTypes(apache::thrift::RpcOptions& rpcOptions, std::unique_ptr callback, const ::facebook::thrift::test::HeapAllocated& p_arg) { auto [ctx, header] = adaptedTypesCtx(&rpcOptions); auto [wrappedCallback, contextStack] = apache::thrift::GeneratedAsyncClient::template prepareRequestClientCallback(std::move(callback), std::move(ctx)); fbthrift_serialize_and_send_adaptedTypes(rpcOptions, std::move(header), contextStack, std::move(wrappedCallback), p_arg); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::fbthrift_serialize_and_send_adaptedTypes(apache::thrift::RpcOptions& rpcOptions, std::shared_ptr header, apache::thrift::ContextStack* contextStack, apache::thrift::RequestClientCallback::Ptr callback, const ::facebook::thrift::test::HeapAllocated& p_arg, bool stealRpcOptions) { apache::thrift::detail::ac::withProtocolWriter(apache::thrift::GeneratedAsyncClient::getChannel()->getProtocolId(), [&](auto&& writer) { apache::thrift::SerializedRequest request = fbthrift_serialize_adaptedTypes(&writer, rpcOptions, *header, contextStack, p_arg); if (stealRpcOptions) { fbthrift_send_adaptedTypes(std::move(request), std::move(rpcOptions), std::move(header), std::move(callback)); } else { fbthrift_send_adaptedTypes(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<::facebook::thrift::test::AdapterService>::adaptedTypesCtx(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(), "AdapterService.adaptedTypes", *header); return {std::move(ctx), std::move(header)}; } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::sync_adaptedTypes(::facebook::thrift::test::HeapAllocated& _return, const ::facebook::thrift::test::HeapAllocated& p_arg) { ::apache::thrift::RpcOptions rpcOptions; sync_adaptedTypes(rpcOptions, _return, p_arg); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::sync_adaptedTypes(apache::thrift::RpcOptions& rpcOptions, ::facebook::thrift::test::HeapAllocated& _return, const ::facebook::thrift::test::HeapAllocated& 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 = adaptedTypesCtx(&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_adaptedTypes(rpcOptions, std::move(ctxAndHeader.second), ctxAndHeader.first.get(), std::move(wrappedCallback), p_arg); }); #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_adaptedTypes(_return, returnState); }); } folly::Future<::facebook::thrift::test::HeapAllocated> apache::thrift::Client<::facebook::thrift::test::AdapterService>::future_adaptedTypes(const ::facebook::thrift::test::HeapAllocated& p_arg) { ::apache::thrift::RpcOptions rpcOptions; return future_adaptedTypes(rpcOptions, p_arg); } folly::SemiFuture<::facebook::thrift::test::HeapAllocated> apache::thrift::Client<::facebook::thrift::test::AdapterService>::semifuture_adaptedTypes(const ::facebook::thrift::test::HeapAllocated& p_arg) { ::apache::thrift::RpcOptions rpcOptions; return semifuture_adaptedTypes(rpcOptions, p_arg); } folly::Future<::facebook::thrift::test::HeapAllocated> apache::thrift::Client<::facebook::thrift::test::AdapterService>::future_adaptedTypes(apache::thrift::RpcOptions& rpcOptions, const ::facebook::thrift::test::HeapAllocated& p_arg) { using CallbackHelper = apache::thrift::detail::FutureCallbackHelper<::facebook::thrift::test::HeapAllocated>; folly::Promise promise; auto future = promise.getFuture(); auto callback = std::make_unique>(std::move(promise), recv_wrapped_adaptedTypes, channel_); adaptedTypes(rpcOptions, std::move(callback), p_arg); return std::move(future).thenValue(CallbackHelper::extractResult); } folly::SemiFuture<::facebook::thrift::test::HeapAllocated> apache::thrift::Client<::facebook::thrift::test::AdapterService>::semifuture_adaptedTypes(apache::thrift::RpcOptions& rpcOptions, const ::facebook::thrift::test::HeapAllocated& p_arg) { auto callbackAndFuture = makeSemiFutureCallback(recv_wrapped_adaptedTypes, channel_); auto callback = std::move(callbackAndFuture.first); adaptedTypes(rpcOptions, std::move(callback), p_arg); return std::move(callbackAndFuture.second); } folly::Future>> apache::thrift::Client<::facebook::thrift::test::AdapterService>::header_future_adaptedTypes(apache::thrift::RpcOptions& rpcOptions, const ::facebook::thrift::test::HeapAllocated& p_arg) { using CallbackHelper = apache::thrift::detail::FutureCallbackHelper>>; folly::Promise promise; auto future = promise.getFuture(); auto callback = std::make_unique>(std::move(promise), recv_wrapped_adaptedTypes, channel_); adaptedTypes(rpcOptions, std::move(callback), p_arg); return std::move(future).thenValue(CallbackHelper::extractResult); } folly::SemiFuture>> apache::thrift::Client<::facebook::thrift::test::AdapterService>::header_semifuture_adaptedTypes(apache::thrift::RpcOptions& rpcOptions, const ::facebook::thrift::test::HeapAllocated& p_arg) { auto callbackAndFuture = makeHeaderSemiFutureCallback(recv_wrapped_adaptedTypes, channel_); auto callback = std::move(callbackAndFuture.first); adaptedTypes(rpcOptions, std::move(callback), p_arg); return std::move(callbackAndFuture.second); } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::adaptedTypes(folly::Function callback, const ::facebook::thrift::test::HeapAllocated& p_arg) { adaptedTypes(std::make_unique(std::move(callback)), p_arg); } #if FOLLY_HAS_COROUTINES #endif // FOLLY_HAS_COROUTINES folly::exception_wrapper apache::thrift::Client<::facebook::thrift::test::AdapterService>::recv_wrapped_adaptedTypes(::facebook::thrift::test::HeapAllocated& _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 = ::facebook::thrift::test::AdapterService_adaptedTypes_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<::facebook::thrift::test::AdapterService>::recv_adaptedTypes(::facebook::thrift::test::HeapAllocated& _return, ::apache::thrift::ClientReceiveState& state) { auto ew = recv_wrapped_adaptedTypes(_return, state); if (ew) { ew.throw_exception(); } } void apache::thrift::Client<::facebook::thrift::test::AdapterService>::recv_instance_adaptedTypes(::facebook::thrift::test::HeapAllocated& _return, ::apache::thrift::ClientReceiveState& state) { return recv_adaptedTypes(_return, state); } folly::exception_wrapper apache::thrift::Client<::facebook::thrift::test::AdapterService>::recv_instance_wrapped_adaptedTypes(::facebook::thrift::test::HeapAllocated& _return, ::apache::thrift::ClientReceiveState& state) { return recv_wrapped_adaptedTypes(_return, state); }