1 /**
2 * Autogenerated by Thrift for src/module.thrift
3 *
4 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 * @generated @nocommit
6 */
7 #pragma once
8
9 #include "thrift/compiler/test/fixtures/basic-structured-annotations/gen-cpp2/MyService.h"
10
11 #include <thrift/lib/cpp2/gen/service_tcc.h>
12
13 namespace cpp2 {
14 typedef apache::thrift::ThriftPresult<false> MyService_first_pargs;
15 typedef apache::thrift::ThriftPresult<true, apache::thrift::FieldData<0, ::apache::thrift::type_class::string, ::cpp2::annotated_inline_string*>> MyService_first_presult;
16 typedef apache::thrift::ThriftPresult<false, apache::thrift::FieldData<1, ::apache::thrift::type_class::integral, ::std::int64_t*>> MyService_second_pargs;
17 typedef apache::thrift::ThriftPresult<true, apache::thrift::FieldData<0, ::apache::thrift::type_class::integral, bool*>> MyService_second_presult;
18 template <typename ProtocolIn_, typename ProtocolOut_>
setUpAndProcess_first(apache::thrift::ResponseChannelRequest::UniquePtr req,apache::thrift::SerializedCompressedRequest && serializedRequest,apache::thrift::Cpp2RequestContext * ctx,folly::EventBase * eb,apache::thrift::concurrency::ThreadManager * tm)19 void MyServiceAsyncProcessor::setUpAndProcess_first(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
20 if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, iface_)) {
21 return;
22 }
23 auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL);
24 ctx->setRequestExecutionScope(std::move(scope));
25 processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, &MyServiceAsyncProcessor::process_first<ProtocolIn_, ProtocolOut_>, this);
26 }
27
28 template <typename ProtocolIn_, typename ProtocolOut_>
process_first(apache::thrift::ResponseChannelRequest::UniquePtr req,apache::thrift::SerializedCompressedRequest && serializedRequest,apache::thrift::Cpp2RequestContext * ctx,folly::EventBase * eb,apache::thrift::concurrency::ThreadManager * tm)29 void MyServiceAsyncProcessor::process_first(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
30 if (!req->getShouldStartProcessing()) {
31 apache::thrift::HandlerCallbackBase::releaseRequest(std::move(req), eb);
32 return;
33 }
34 // make sure getRequestContext is null
35 // so async calls don't accidentally use it
36 iface_->setRequestContext(nullptr);
37 MyService_first_pargs args;
38 std::unique_ptr<apache::thrift::ContextStack> ctxStack(this->getContextStack(this->getServiceName(), "MyService.first", ctx));
39 try {
40 deserializeRequest<ProtocolIn_>(args, ctx->getMethodName(), std::move(serializedRequest).uncompress(), ctxStack.get());
41 }
42 catch (const std::exception& ex) {
43 folly::exception_wrapper ew(std::current_exception(), ex);
44 apache::thrift::detail::ap::process_handle_exn_deserialization<ProtocolOut_>(
45 ew, std::move(req), ctx, eb, "first");
46 return;
47 }
48 auto callback = std::make_unique<apache::thrift::HandlerCallback<std::unique_ptr<::cpp2::annotated_inline_string>>>(std::move(req), std::move(ctxStack), return_first<ProtocolIn_,ProtocolOut_>, throw_wrapped_first<ProtocolIn_, ProtocolOut_>, ctx->getProtoSeqId(), eb, tm, ctx);
49 iface_->async_tm_first(std::move(callback));
50 }
51
52 template <class ProtocolIn_, class ProtocolOut_>
return_first(apache::thrift::ContextStack * ctx,::cpp2::annotated_inline_string const & _return)53 apache::thrift::SerializedResponse MyServiceAsyncProcessor::return_first(apache::thrift::ContextStack* ctx, ::cpp2::annotated_inline_string const& _return) {
54 ProtocolOut_ prot;
55 MyService_first_presult result;
56 result.get<0>().value = const_cast<::cpp2::annotated_inline_string*>(&_return);
57 result.setIsSet(0, true);
58 return serializeResponse(&prot, ctx, result);
59 }
60
61 template <class ProtocolIn_, class ProtocolOut_>
throw_wrapped_first(apache::thrift::ResponseChannelRequest::UniquePtr req,int32_t protoSeqId,apache::thrift::ContextStack * ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext * reqCtx)62 void MyServiceAsyncProcessor::throw_wrapped_first(apache::thrift::ResponseChannelRequest::UniquePtr req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) {
63 if (!ew) {
64 return;
65 }
66 {
67 (void)protoSeqId;
68 apache::thrift::detail::ap::process_throw_wrapped_handler_error<ProtocolOut_>(
69 ew, std::move(req), reqCtx, ctx, "first");
70 return;
71 }
72 }
73
74 template <typename ProtocolIn_, typename ProtocolOut_>
setUpAndProcess_second(apache::thrift::ResponseChannelRequest::UniquePtr req,apache::thrift::SerializedCompressedRequest && serializedRequest,apache::thrift::Cpp2RequestContext * ctx,folly::EventBase * eb,apache::thrift::concurrency::ThreadManager * tm)75 void MyServiceAsyncProcessor::setUpAndProcess_second(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
76 if (!setUpRequestProcessing(req, ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, iface_)) {
77 return;
78 }
79 auto scope = iface_->getRequestExecutionScope(ctx, apache::thrift::concurrency::NORMAL);
80 ctx->setRequestExecutionScope(std::move(scope));
81 processInThread(std::move(req), std::move(serializedRequest), ctx, eb, tm, apache::thrift::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, &MyServiceAsyncProcessor::process_second<ProtocolIn_, ProtocolOut_>, this);
82 }
83
84 template <typename ProtocolIn_, typename ProtocolOut_>
process_second(apache::thrift::ResponseChannelRequest::UniquePtr req,apache::thrift::SerializedCompressedRequest && serializedRequest,apache::thrift::Cpp2RequestContext * ctx,folly::EventBase * eb,apache::thrift::concurrency::ThreadManager * tm)85 void MyServiceAsyncProcessor::process_second(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedCompressedRequest&& serializedRequest, apache::thrift::Cpp2RequestContext* ctx, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
86 if (!req->getShouldStartProcessing()) {
87 apache::thrift::HandlerCallbackBase::releaseRequest(std::move(req), eb);
88 return;
89 }
90 // make sure getRequestContext is null
91 // so async calls don't accidentally use it
92 iface_->setRequestContext(nullptr);
93 MyService_second_pargs args;
94 ::std::int64_t uarg_count{0};
95 args.get<0>().value = &uarg_count;
96 std::unique_ptr<apache::thrift::ContextStack> ctxStack(this->getContextStack(this->getServiceName(), "MyService.second", ctx));
97 try {
98 deserializeRequest<ProtocolIn_>(args, ctx->getMethodName(), std::move(serializedRequest).uncompress(), ctxStack.get());
99 }
100 catch (const std::exception& ex) {
101 folly::exception_wrapper ew(std::current_exception(), ex);
102 apache::thrift::detail::ap::process_handle_exn_deserialization<ProtocolOut_>(
103 ew, std::move(req), ctx, eb, "second");
104 return;
105 }
106 auto callback = std::make_unique<apache::thrift::HandlerCallback<bool>>(std::move(req), std::move(ctxStack), return_second<ProtocolIn_,ProtocolOut_>, throw_wrapped_second<ProtocolIn_, ProtocolOut_>, ctx->getProtoSeqId(), eb, tm, ctx);
107 iface_->async_tm_second(std::move(callback), args.get<0>().ref());
108 }
109
110 template <class ProtocolIn_, class ProtocolOut_>
return_second(apache::thrift::ContextStack * ctx,bool const & _return)111 apache::thrift::SerializedResponse MyServiceAsyncProcessor::return_second(apache::thrift::ContextStack* ctx, bool const& _return) {
112 ProtocolOut_ prot;
113 MyService_second_presult result;
114 result.get<0>().value = const_cast<bool*>(&_return);
115 result.setIsSet(0, true);
116 return serializeResponse(&prot, ctx, result);
117 }
118
119 template <class ProtocolIn_, class ProtocolOut_>
throw_wrapped_second(apache::thrift::ResponseChannelRequest::UniquePtr req,int32_t protoSeqId,apache::thrift::ContextStack * ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext * reqCtx)120 void MyServiceAsyncProcessor::throw_wrapped_second(apache::thrift::ResponseChannelRequest::UniquePtr req,int32_t protoSeqId,apache::thrift::ContextStack* ctx,folly::exception_wrapper ew,apache::thrift::Cpp2RequestContext* reqCtx) {
121 if (!ew) {
122 return;
123 }
124 {
125 (void)protoSeqId;
126 apache::thrift::detail::ap::process_throw_wrapped_handler_error<ProtocolOut_>(
127 ew, std::move(req), reqCtx, ctx, "second");
128 return;
129 }
130 }
131
132
133 } // cpp2
134