/** * Autogenerated by Thrift for thrift/compiler/test/fixtures/sink/src/module.thrift * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated @nocommit */ #pragma once #include "thrift/compiler/test/fixtures/sink/gen-cpp2/SinkService.h" #include namespace cpp2 { typedef apache::thrift::ThriftPresult SinkService_method_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > SinkService_method_presult; typedef apache::thrift::ThriftPresult SinkService_methodAndReponse_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > SinkService_methodAndReponse_presult; typedef apache::thrift::ThriftPresult SinkService_methodThrow_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > SinkService_methodThrow_presult; typedef apache::thrift::ThriftPresult SinkService_methodSinkThrow_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult, apache::thrift::FieldData<1, ::apache::thrift::type_class::structure, ::cpp2::SinkException1>>, apache::thrift::ThriftPresult> > SinkService_methodSinkThrow_presult; typedef apache::thrift::ThriftPresult SinkService_methodFinalThrow_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult, apache::thrift::FieldData<1, ::apache::thrift::type_class::structure, ::cpp2::SinkException2>> > SinkService_methodFinalThrow_presult; typedef apache::thrift::ThriftPresult SinkService_methodBothThrow_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult, apache::thrift::FieldData<1, ::apache::thrift::type_class::structure, ::cpp2::SinkException1>>, apache::thrift::ThriftPresult, apache::thrift::FieldData<1, ::apache::thrift::type_class::structure, ::cpp2::SinkException2>> > SinkService_methodBothThrow_presult; typedef apache::thrift::ThriftPresult SinkService_methodFast_pargs; typedef apache::thrift::ThriftPResultSink< apache::thrift::ThriftPresult, apache::thrift::ThriftPresult>, apache::thrift::ThriftPresult> > SinkService_methodFast_presult; template void SinkServiceAsyncProcessor::setUpAndProcess_method(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINK, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINK, &SinkServiceAsyncProcessor::executeRequest_method, this); } template void SinkServiceAsyncProcessor::executeRequest_method(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { SinkService_method_pargs pargs() { SinkService_method_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "SinkService.method", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "method", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "method"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr<::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "method" , return_method , throw_wrapped_method , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_method(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template std::pair SinkServiceAsyncProcessor::return_method(apache::thrift::ContextStack* ctx, ::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>&& _return, folly::Executor::KeepAlive<> executor) { ProtocolOut_ prot; SinkService_method_presult::FieldsType result; using SinkPResultType = SinkService_method_presult::SinkPResultType; using FinalResponsePResultType = SinkService_method_presult::FinalResponsePResultType; using ExMapType = apache::thrift::detail::ap::EmptyExMapType; auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( std::move(_return), std::move(executor)); return {serializeResponse("method", &prot, ctx, result), std::move(sinkConsumerImpl)}; } template void SinkServiceAsyncProcessor::throw_wrapped_method(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "method"); return; } } template void SinkServiceAsyncProcessor::setUpAndProcess_methodAndReponse(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINK, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINK, &SinkServiceAsyncProcessor::executeRequest_methodAndReponse, this); } template void SinkServiceAsyncProcessor::executeRequest_methodAndReponse(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { SinkService_methodAndReponse_pargs pargs() { SinkService_methodAndReponse_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "SinkService.methodAndReponse", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "methodAndReponse", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "methodAndReponse"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr<::apache::thrift::ResponseAndSinkConsumer<::cpp2::InitialResponse, ::cpp2::SinkPayload, ::cpp2::FinalResponse>>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "methodAndReponse" , return_methodAndReponse , throw_wrapped_methodAndReponse , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_methodAndReponse(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template std::pair SinkServiceAsyncProcessor::return_methodAndReponse(apache::thrift::ContextStack* ctx, ::apache::thrift::ResponseAndSinkConsumer<::cpp2::InitialResponse, ::cpp2::SinkPayload, ::cpp2::FinalResponse>&& _return, folly::Executor::KeepAlive<> executor) { ProtocolOut_ prot; SinkService_methodAndReponse_presult::FieldsType result; using SinkPResultType = SinkService_methodAndReponse_presult::SinkPResultType; using FinalResponsePResultType = SinkService_methodAndReponse_presult::FinalResponsePResultType; result.get<0>().value = &_return.response; result.setIsSet(0, true); using ExMapType = apache::thrift::detail::ap::EmptyExMapType; auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( std::move(_return.sinkConsumer), std::move(executor)); return {serializeResponse("methodAndReponse", &prot, ctx, result), std::move(sinkConsumerImpl)}; } template void SinkServiceAsyncProcessor::throw_wrapped_methodAndReponse(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "methodAndReponse"); return; } } template void SinkServiceAsyncProcessor::setUpAndProcess_methodThrow(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINK, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINK, &SinkServiceAsyncProcessor::executeRequest_methodThrow, this); } template void SinkServiceAsyncProcessor::executeRequest_methodThrow(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { SinkService_methodThrow_pargs pargs() { SinkService_methodThrow_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "SinkService.methodThrow", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "methodThrow", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "methodThrow"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr<::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "methodThrow" , return_methodThrow , throw_wrapped_methodThrow , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_methodThrow(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template std::pair SinkServiceAsyncProcessor::return_methodThrow(apache::thrift::ContextStack* ctx, ::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>&& _return, folly::Executor::KeepAlive<> executor) { ProtocolOut_ prot; SinkService_methodThrow_presult::FieldsType result; using SinkPResultType = SinkService_methodThrow_presult::SinkPResultType; using FinalResponsePResultType = SinkService_methodThrow_presult::FinalResponsePResultType; using ExMapType = apache::thrift::detail::ap::EmptyExMapType; auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( std::move(_return), std::move(executor)); return {serializeResponse("methodThrow", &prot, ctx, result), std::move(sinkConsumerImpl)}; } template void SinkServiceAsyncProcessor::throw_wrapped_methodThrow(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } ::cpp2::SinkService_methodThrow_presult result; if (ew.with_exception([&]( ::cpp2::InitialException& e) { if (ctx) { ctx->userExceptionWrapped(true, ew); } ::apache::thrift::util::appendExceptionToHeader(ew, *reqCtx); ::apache::thrift::util::appendErrorClassificationToHeader< ::cpp2::InitialException>(ew, *reqCtx); result.fields.get<0>().ref() = e; result.fields.setIsSet(0, true); } )) {} else { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "methodThrow"); return; } ProtocolOut_ prot; auto response = serializeResponse("methodThrow", &prot, ctx, result.fields); auto payload = std::move(response).extractPayload( req->includeEnvelope(), prot.protocolType(), protoSeqId, apache::thrift::MessageType::T_REPLY, "methodThrow"); payload.transform(reqCtx->getHeader()->getWriteTransforms()); req->sendSinkReply(std::move(payload), apache::thrift::detail::SinkConsumerImpl{}); } template void SinkServiceAsyncProcessor::setUpAndProcess_methodSinkThrow(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINK, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINK, &SinkServiceAsyncProcessor::executeRequest_methodSinkThrow, this); } template void SinkServiceAsyncProcessor::executeRequest_methodSinkThrow(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { SinkService_methodSinkThrow_pargs pargs() { SinkService_methodSinkThrow_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "SinkService.methodSinkThrow", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "methodSinkThrow", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "methodSinkThrow"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr<::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "methodSinkThrow" , return_methodSinkThrow , throw_wrapped_methodSinkThrow , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_methodSinkThrow(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template std::pair SinkServiceAsyncProcessor::return_methodSinkThrow(apache::thrift::ContextStack* ctx, ::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>&& _return, folly::Executor::KeepAlive<> executor) { ProtocolOut_ prot; SinkService_methodSinkThrow_presult::FieldsType result; using SinkPResultType = SinkService_methodSinkThrow_presult::SinkPResultType; using FinalResponsePResultType = SinkService_methodSinkThrow_presult::FinalResponsePResultType; using ExMapType = apache::thrift::detail::ap::EmptyExMapType; auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( std::move(_return), std::move(executor)); return {serializeResponse("methodSinkThrow", &prot, ctx, result), std::move(sinkConsumerImpl)}; } template void SinkServiceAsyncProcessor::throw_wrapped_methodSinkThrow(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "methodSinkThrow"); return; } } template void SinkServiceAsyncProcessor::setUpAndProcess_methodFinalThrow(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINK, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINK, &SinkServiceAsyncProcessor::executeRequest_methodFinalThrow, this); } template void SinkServiceAsyncProcessor::executeRequest_methodFinalThrow(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { SinkService_methodFinalThrow_pargs pargs() { SinkService_methodFinalThrow_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "SinkService.methodFinalThrow", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "methodFinalThrow", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "methodFinalThrow"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr<::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "methodFinalThrow" , return_methodFinalThrow , throw_wrapped_methodFinalThrow , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_methodFinalThrow(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template std::pair SinkServiceAsyncProcessor::return_methodFinalThrow(apache::thrift::ContextStack* ctx, ::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>&& _return, folly::Executor::KeepAlive<> executor) { ProtocolOut_ prot; SinkService_methodFinalThrow_presult::FieldsType result; using SinkPResultType = SinkService_methodFinalThrow_presult::SinkPResultType; using FinalResponsePResultType = SinkService_methodFinalThrow_presult::FinalResponsePResultType; struct ExMapType { bool operator()(FinalResponsePResultType& res, folly::exception_wrapper ew) { if (ew.with_exception([&]( ::cpp2::SinkException2& e) { res.get<1>().ref() = e; res.setIsSet(1, true); })) { return true; } return false; } }; auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( std::move(_return), std::move(executor)); return {serializeResponse("methodFinalThrow", &prot, ctx, result), std::move(sinkConsumerImpl)}; } template void SinkServiceAsyncProcessor::throw_wrapped_methodFinalThrow(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "methodFinalThrow"); return; } } template void SinkServiceAsyncProcessor::setUpAndProcess_methodBothThrow(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINK, iface_)) { return; } auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL); ctx->setRequestExecutionScope(std::move(scope)); processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINK, &SinkServiceAsyncProcessor::executeRequest_methodBothThrow, this); } template void SinkServiceAsyncProcessor::executeRequest_methodBothThrow(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { SinkService_methodBothThrow_pargs pargs() { SinkService_methodBothThrow_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "SinkService.methodBothThrow", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "methodBothThrow", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "methodBothThrow"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr<::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "methodBothThrow" , return_methodBothThrow , throw_wrapped_methodBothThrow , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , apache::thrift::detail::ServerRequestHelper::executor(serverRequest) , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_tm_methodBothThrow(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template std::pair SinkServiceAsyncProcessor::return_methodBothThrow(apache::thrift::ContextStack* ctx, ::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>&& _return, folly::Executor::KeepAlive<> executor) { ProtocolOut_ prot; SinkService_methodBothThrow_presult::FieldsType result; using SinkPResultType = SinkService_methodBothThrow_presult::SinkPResultType; using FinalResponsePResultType = SinkService_methodBothThrow_presult::FinalResponsePResultType; struct ExMapType { bool operator()(FinalResponsePResultType& res, folly::exception_wrapper ew) { if (ew.with_exception([&]( ::cpp2::SinkException2& e) { res.get<1>().ref() = e; res.setIsSet(1, true); })) { return true; } return false; } }; auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( std::move(_return), std::move(executor)); return {serializeResponse("methodBothThrow", &prot, ctx, result), std::move(sinkConsumerImpl)}; } template void SinkServiceAsyncProcessor::throw_wrapped_methodBothThrow(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "methodBothThrow"); return; } } template void SinkServiceAsyncProcessor::setUpAndProcess_methodFast(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, [[maybe_unused]] apache::thrift::concurrency::ThreadManager* tm) { if (!setUpRequestProcessing(req, ctx, eb, nullptr, apache::thrift::RpcKind::SINK, iface_)) { return; } if (!req->getShouldStartProcessing()) { apache::thrift::HandlerCallbackBase::releaseRequest(std::move(req), eb); return; } apache::thrift::ServerRequest serverRequest{std::move(req), std::move(serializedRequest), ctx, {}, {}, {}, {}}; executeRequest_methodFast(std::move(serverRequest)); } template void SinkServiceAsyncProcessor::executeRequest_methodFast(apache::thrift::ServerRequest&& serverRequest) { // make sure getRequestContext is null // so async calls don't accidentally use it iface_->setRequestContext(nullptr); struct ArgsState { SinkService_methodFast_pargs pargs() { SinkService_methodFast_pargs args; return args; } auto asTupleOfRefs() & { return std::tie( ); } } args; auto ctxStack = apache::thrift::ContextStack::create( this->getEventHandlersSharedPtr(), this->getServiceName(), "SinkService.methodFast", serverRequest.requestContext()); try { auto pargs = args.pargs(); deserializeRequest(pargs, "methodFast", apache::thrift::detail::ServerRequestHelper::compressedRequest(std::move(serverRequest)).uncompress(), ctxStack.get()); } catch (...) { folly::exception_wrapper ew(std::current_exception()); apache::thrift::detail::ap::process_handle_exn_deserialization( ew , apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , serverRequest.requestContext() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , "methodFast"); return; } auto requestPileNotification = apache::thrift::detail::ServerRequestHelper::moveRequestPileNotification(serverRequest); auto concurrencyControllerNotification = apache::thrift::detail::ServerRequestHelper::moveConcurrencyControllerNotification(serverRequest); auto callback = apache::thrift::HandlerCallbackPtr<::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>>::make( apache::thrift::detail::ServerRequestHelper::request(std::move(serverRequest)) , std::move(ctxStack) , this->getServiceName() , "methodFast" , return_methodFast , throw_wrapped_methodFast , serverRequest.requestContext()->getProtoSeqId() , apache::thrift::detail::ServerRequestHelper::eventBase(serverRequest) , nullptr , serverRequest.requestContext() , requestPileNotification , concurrencyControllerNotification, std::move(serverRequest.requestData()) ); const auto makeExecuteHandler = [&] { return [ifacePtr = iface_](auto&& cb, ArgsState args) mutable { (void)args; ifacePtr->async_eb_methodFast(std::move(cb)); }; }; #if FOLLY_HAS_COROUTINES if (apache::thrift::detail::shouldProcessServiceInterceptorsOnRequest(*callback)) { [](auto callback, auto executeHandler, ArgsState args) -> folly::coro::Task { auto argRefs = args.asTupleOfRefs(); co_await apache::thrift::detail::processServiceInterceptorsOnRequest( *callback, apache::thrift::detail::ServiceInterceptorOnRequestArguments(argRefs)); executeHandler(std::move(callback), std::move(args)); }(std::move(callback), makeExecuteHandler(), std::move(args)) .scheduleOn(apache::thrift::detail::ServerRequestHelper::executor(serverRequest)) .startInlineUnsafe(); } else { makeExecuteHandler()(std::move(callback), std::move(args)); } #else makeExecuteHandler()(std::move(callback), std::move(args)); #endif // FOLLY_HAS_COROUTINES } template std::pair SinkServiceAsyncProcessor::return_methodFast(apache::thrift::ContextStack* ctx, ::apache::thrift::SinkConsumer<::cpp2::SinkPayload, ::cpp2::FinalResponse>&& _return, folly::Executor::KeepAlive<> executor) { ProtocolOut_ prot; SinkService_methodFast_presult::FieldsType result; using SinkPResultType = SinkService_methodFast_presult::SinkPResultType; using FinalResponsePResultType = SinkService_methodFast_presult::FinalResponsePResultType; using ExMapType = apache::thrift::detail::ap::EmptyExMapType; auto sinkConsumerImpl = apache::thrift::detail::ap::toSinkConsumerImpl< ProtocolIn_, ProtocolOut_, SinkPResultType, FinalResponsePResultType, ExMapType>( std::move(_return), std::move(executor)); return {serializeResponse("methodFast", &prot, ctx, result), std::move(sinkConsumerImpl)}; } template void SinkServiceAsyncProcessor::throw_wrapped_methodFast(apache::thrift::ResponseChannelRequest::UniquePtr req,[[maybe_unused]] int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) { if (!ew) { return; } { apache::thrift::detail::ap::process_throw_wrapped_handler_error( ew, std::move(req), reqCtx, ctx, "methodFast"); return; } } } // namespace cpp2