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 #include <thrift/lib/cpp2/gen/module_metadata_cpp.h>
8 #include "thrift/compiler/test/fixtures/exceptions/gen-cpp2/module_metadata.h"
9 
10 namespace apache {
11 namespace thrift {
12 namespace detail {
13 namespace md {
14 using ThriftMetadata = ::apache::thrift::metadata::ThriftMetadata;
15 using ThriftPrimitiveType = ::apache::thrift::metadata::ThriftPrimitiveType;
16 using ThriftType = ::apache::thrift::metadata::ThriftType;
17 using ThriftService = ::apache::thrift::metadata::ThriftService;
18 using ThriftServiceContext = ::apache::thrift::metadata::ThriftServiceContext;
19 using ThriftFunctionGenerator = void (*)(ThriftMetadata&, ThriftService&);
20 
21 
22 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)23 StructMetadata<::cpp2::Fiery>::gen(ThriftMetadata& metadata) {
24   auto res = metadata.structs_ref()->emplace("module.Fiery", ::apache::thrift::metadata::ThriftStruct{});
25   if (!res.second) {
26     return res.first->second;
27   }
28   ::apache::thrift::metadata::ThriftStruct& module_Fiery = res.first->second;
29   module_Fiery.name_ref() = "module.Fiery";
30   module_Fiery.is_union_ref() = false;
31   static const EncodedThriftField
32   module_Fiery_fields[] = {
33     {1, "message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
34   };
35   for (const auto& f : module_Fiery_fields) {
36     ::apache::thrift::metadata::ThriftField field;
37     field.id_ref() = f.id;
38     field.name_ref() = f.name;
39     field.is_optional_ref() = f.is_optional;
40     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
41     field.structured_annotations_ref() = f.structured_annotations;
42     module_Fiery.fields_ref()->push_back(std::move(field));
43   }
44   return res.first->second;
45 }
46 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)47 StructMetadata<::cpp2::Serious>::gen(ThriftMetadata& metadata) {
48   auto res = metadata.structs_ref()->emplace("module.Serious", ::apache::thrift::metadata::ThriftStruct{});
49   if (!res.second) {
50     return res.first->second;
51   }
52   ::apache::thrift::metadata::ThriftStruct& module_Serious = res.first->second;
53   module_Serious.name_ref() = "module.Serious";
54   module_Serious.is_union_ref() = false;
55   static const EncodedThriftField
56   module_Serious_fields[] = {
57     {1, "sonnet", true, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
58   };
59   for (const auto& f : module_Serious_fields) {
60     ::apache::thrift::metadata::ThriftField field;
61     field.id_ref() = f.id;
62     field.name_ref() = f.name;
63     field.is_optional_ref() = f.is_optional;
64     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
65     field.structured_annotations_ref() = f.structured_annotations;
66     module_Serious.fields_ref()->push_back(std::move(field));
67   }
68   return res.first->second;
69 }
70 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)71 StructMetadata<::cpp2::ComplexFieldNames>::gen(ThriftMetadata& metadata) {
72   auto res = metadata.structs_ref()->emplace("module.ComplexFieldNames", ::apache::thrift::metadata::ThriftStruct{});
73   if (!res.second) {
74     return res.first->second;
75   }
76   ::apache::thrift::metadata::ThriftStruct& module_ComplexFieldNames = res.first->second;
77   module_ComplexFieldNames.name_ref() = "module.ComplexFieldNames";
78   module_ComplexFieldNames.is_union_ref() = false;
79   static const EncodedThriftField
80   module_ComplexFieldNames_fields[] = {
81     {1, "error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
82     {2, "internal_error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
83   };
84   for (const auto& f : module_ComplexFieldNames_fields) {
85     ::apache::thrift::metadata::ThriftField field;
86     field.id_ref() = f.id;
87     field.name_ref() = f.name;
88     field.is_optional_ref() = f.is_optional;
89     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
90     field.structured_annotations_ref() = f.structured_annotations;
91     module_ComplexFieldNames.fields_ref()->push_back(std::move(field));
92   }
93   return res.first->second;
94 }
95 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)96 StructMetadata<::cpp2::CustomFieldNames>::gen(ThriftMetadata& metadata) {
97   auto res = metadata.structs_ref()->emplace("module.CustomFieldNames", ::apache::thrift::metadata::ThriftStruct{});
98   if (!res.second) {
99     return res.first->second;
100   }
101   ::apache::thrift::metadata::ThriftStruct& module_CustomFieldNames = res.first->second;
102   module_CustomFieldNames.name_ref() = "module.CustomFieldNames";
103   module_CustomFieldNames.is_union_ref() = false;
104   static const EncodedThriftField
105   module_CustomFieldNames_fields[] = {
106     {1, "error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
107     {2, "internal_error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
108   };
109   for (const auto& f : module_CustomFieldNames_fields) {
110     ::apache::thrift::metadata::ThriftField field;
111     field.id_ref() = f.id;
112     field.name_ref() = f.name;
113     field.is_optional_ref() = f.is_optional;
114     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
115     field.structured_annotations_ref() = f.structured_annotations;
116     module_CustomFieldNames.fields_ref()->push_back(std::move(field));
117   }
118   return res.first->second;
119 }
120 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)121 StructMetadata<::cpp2::ExceptionWithPrimitiveField>::gen(ThriftMetadata& metadata) {
122   auto res = metadata.structs_ref()->emplace("module.ExceptionWithPrimitiveField", ::apache::thrift::metadata::ThriftStruct{});
123   if (!res.second) {
124     return res.first->second;
125   }
126   ::apache::thrift::metadata::ThriftStruct& module_ExceptionWithPrimitiveField = res.first->second;
127   module_ExceptionWithPrimitiveField.name_ref() = "module.ExceptionWithPrimitiveField";
128   module_ExceptionWithPrimitiveField.is_union_ref() = false;
129   static const EncodedThriftField
130   module_ExceptionWithPrimitiveField_fields[] = {
131     {1, "message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
132     {2, "error_code", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
133   };
134   for (const auto& f : module_ExceptionWithPrimitiveField_fields) {
135     ::apache::thrift::metadata::ThriftField field;
136     field.id_ref() = f.id;
137     field.name_ref() = f.name;
138     field.is_optional_ref() = f.is_optional;
139     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
140     field.structured_annotations_ref() = f.structured_annotations;
141     module_ExceptionWithPrimitiveField.fields_ref()->push_back(std::move(field));
142   }
143   return res.first->second;
144 }
145 const ::apache::thrift::metadata::ThriftStruct&
gen(ThriftMetadata & metadata)146 StructMetadata<::cpp2::Banal>::gen(ThriftMetadata& metadata) {
147   auto res = metadata.structs_ref()->emplace("module.Banal", ::apache::thrift::metadata::ThriftStruct{});
148   if (!res.second) {
149     return res.first->second;
150   }
151   ::apache::thrift::metadata::ThriftStruct& module_Banal = res.first->second;
152   module_Banal.name_ref() = "module.Banal";
153   module_Banal.is_union_ref() = false;
154   return res.first->second;
155 }
156 
gen(ThriftMetadata & metadata)157 void ExceptionMetadata<::cpp2::Fiery>::gen(ThriftMetadata& metadata) {
158   auto res = metadata.exceptions_ref()->emplace("module.Fiery", ::apache::thrift::metadata::ThriftException{});
159   if (!res.second) {
160     return;
161   }
162   ::apache::thrift::metadata::ThriftException& module_Fiery = res.first->second;
163   module_Fiery.name_ref() = "module.Fiery";
164   static const EncodedThriftField
165   module_Fiery_fields[] = {
166     {1, "message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
167   };
168   for (const auto& f : module_Fiery_fields) {
169     ::apache::thrift::metadata::ThriftField field;
170     field.id_ref() = f.id;
171     field.name_ref() = f.name;
172     field.is_optional_ref() = f.is_optional;
173     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
174     module_Fiery.fields_ref()->push_back(std::move(field));
175   }
176 }
gen(ThriftMetadata & metadata)177 void ExceptionMetadata<::cpp2::Serious>::gen(ThriftMetadata& metadata) {
178   auto res = metadata.exceptions_ref()->emplace("module.Serious", ::apache::thrift::metadata::ThriftException{});
179   if (!res.second) {
180     return;
181   }
182   ::apache::thrift::metadata::ThriftException& module_Serious = res.first->second;
183   module_Serious.name_ref() = "module.Serious";
184   static const EncodedThriftField
185   module_Serious_fields[] = {
186     {1, "sonnet", true, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
187   };
188   for (const auto& f : module_Serious_fields) {
189     ::apache::thrift::metadata::ThriftField field;
190     field.id_ref() = f.id;
191     field.name_ref() = f.name;
192     field.is_optional_ref() = f.is_optional;
193     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
194     module_Serious.fields_ref()->push_back(std::move(field));
195   }
196 }
gen(ThriftMetadata & metadata)197 void ExceptionMetadata<::cpp2::ComplexFieldNames>::gen(ThriftMetadata& metadata) {
198   auto res = metadata.exceptions_ref()->emplace("module.ComplexFieldNames", ::apache::thrift::metadata::ThriftException{});
199   if (!res.second) {
200     return;
201   }
202   ::apache::thrift::metadata::ThriftException& module_ComplexFieldNames = res.first->second;
203   module_ComplexFieldNames.name_ref() = "module.ComplexFieldNames";
204   static const EncodedThriftField
205   module_ComplexFieldNames_fields[] = {
206     {1, "error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
207     {2, "internal_error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
208   };
209   for (const auto& f : module_ComplexFieldNames_fields) {
210     ::apache::thrift::metadata::ThriftField field;
211     field.id_ref() = f.id;
212     field.name_ref() = f.name;
213     field.is_optional_ref() = f.is_optional;
214     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
215     module_ComplexFieldNames.fields_ref()->push_back(std::move(field));
216   }
217 }
gen(ThriftMetadata & metadata)218 void ExceptionMetadata<::cpp2::CustomFieldNames>::gen(ThriftMetadata& metadata) {
219   auto res = metadata.exceptions_ref()->emplace("module.CustomFieldNames", ::apache::thrift::metadata::ThriftException{});
220   if (!res.second) {
221     return;
222   }
223   ::apache::thrift::metadata::ThriftException& module_CustomFieldNames = res.first->second;
224   module_CustomFieldNames.name_ref() = "module.CustomFieldNames";
225   static const EncodedThriftField
226   module_CustomFieldNames_fields[] = {
227     {1, "error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
228     {2, "internal_error_message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
229   };
230   for (const auto& f : module_CustomFieldNames_fields) {
231     ::apache::thrift::metadata::ThriftField field;
232     field.id_ref() = f.id;
233     field.name_ref() = f.name;
234     field.is_optional_ref() = f.is_optional;
235     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
236     module_CustomFieldNames.fields_ref()->push_back(std::move(field));
237   }
238 }
gen(ThriftMetadata & metadata)239 void ExceptionMetadata<::cpp2::ExceptionWithPrimitiveField>::gen(ThriftMetadata& metadata) {
240   auto res = metadata.exceptions_ref()->emplace("module.ExceptionWithPrimitiveField", ::apache::thrift::metadata::ThriftException{});
241   if (!res.second) {
242     return;
243   }
244   ::apache::thrift::metadata::ThriftException& module_ExceptionWithPrimitiveField = res.first->second;
245   module_ExceptionWithPrimitiveField.name_ref() = "module.ExceptionWithPrimitiveField";
246   static const EncodedThriftField
247   module_ExceptionWithPrimitiveField_fields[] = {
248     {1, "message", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE), std::vector<ThriftConstStruct>{}},
249     {2, "error_code", false, std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_I32_TYPE), std::vector<ThriftConstStruct>{}},
250   };
251   for (const auto& f : module_ExceptionWithPrimitiveField_fields) {
252     ::apache::thrift::metadata::ThriftField field;
253     field.id_ref() = f.id;
254     field.name_ref() = f.name;
255     field.is_optional_ref() = f.is_optional;
256     f.metadata_type_interface->writeAndGenType(*field.type_ref(), metadata);
257     module_ExceptionWithPrimitiveField.fields_ref()->push_back(std::move(field));
258   }
259 }
gen(ThriftMetadata & metadata)260 void ExceptionMetadata<::cpp2::Banal>::gen(ThriftMetadata& metadata) {
261   auto res = metadata.exceptions_ref()->emplace("module.Banal", ::apache::thrift::metadata::ThriftException{});
262   if (!res.second) {
263     return;
264   }
265   ::apache::thrift::metadata::ThriftException& module_Banal = res.first->second;
266   module_Banal.name_ref() = "module.Banal";
267 }
gen_doBland(ThriftMetadata & metadata,ThriftService & service)268 void ServiceMetadata<::cpp2::RaiserSvIf>::gen_doBland(ThriftMetadata& metadata, ThriftService& service) {
269   ::apache::thrift::metadata::ThriftFunction func;
270   (void)metadata;
271   func.name_ref() = "doBland";
272   auto func_ret_type = std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_VOID_TYPE);
273   func_ret_type->writeAndGenType(*func.return_type_ref(), metadata);
274   func.is_oneway_ref() = false;
275   service.functions_ref()->push_back(std::move(func));
276 }
gen_doRaise(ThriftMetadata & metadata,ThriftService & service)277 void ServiceMetadata<::cpp2::RaiserSvIf>::gen_doRaise(ThriftMetadata& metadata, ThriftService& service) {
278   ::apache::thrift::metadata::ThriftFunction func;
279   (void)metadata;
280   func.name_ref() = "doRaise";
281   auto func_ret_type = std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_VOID_TYPE);
282   func_ret_type->writeAndGenType(*func.return_type_ref(), metadata);
283   ::apache::thrift::metadata::ThriftField module_Raiser_doRaise_b_1;
284   module_Raiser_doRaise_b_1.id_ref() = 1;
285   module_Raiser_doRaise_b_1.name_ref() = "b";
286   module_Raiser_doRaise_b_1.is_optional_ref() = false;
287   auto module_Raiser_doRaise_b_1_type = std::make_unique<Typedef>("module.Banal", std::make_unique<Struct< ::cpp2::Banal>>("module.Banal"), std::vector<ThriftConstStruct>{});
288   module_Raiser_doRaise_b_1_type->writeAndGenType(*module_Raiser_doRaise_b_1.type_ref(), metadata);
289   func.exceptions_ref()->push_back(std::move(module_Raiser_doRaise_b_1));
290   ExceptionMetadata< ::cpp2::Banal>::gen(metadata);
291   ::apache::thrift::metadata::ThriftField module_Raiser_doRaise_f_2;
292   module_Raiser_doRaise_f_2.id_ref() = 2;
293   module_Raiser_doRaise_f_2.name_ref() = "f";
294   module_Raiser_doRaise_f_2.is_optional_ref() = false;
295   auto module_Raiser_doRaise_f_2_type = std::make_unique<Struct< ::cpp2::Fiery>>("module.Fiery");
296   module_Raiser_doRaise_f_2_type->writeAndGenType(*module_Raiser_doRaise_f_2.type_ref(), metadata);
297   func.exceptions_ref()->push_back(std::move(module_Raiser_doRaise_f_2));
298   ExceptionMetadata< ::cpp2::Fiery>::gen(metadata);
299   ::apache::thrift::metadata::ThriftField module_Raiser_doRaise_s_3;
300   module_Raiser_doRaise_s_3.id_ref() = 3;
301   module_Raiser_doRaise_s_3.name_ref() = "s";
302   module_Raiser_doRaise_s_3.is_optional_ref() = false;
303   auto module_Raiser_doRaise_s_3_type = std::make_unique<Struct< ::cpp2::Serious>>("module.Serious");
304   module_Raiser_doRaise_s_3_type->writeAndGenType(*module_Raiser_doRaise_s_3.type_ref(), metadata);
305   func.exceptions_ref()->push_back(std::move(module_Raiser_doRaise_s_3));
306   ExceptionMetadata< ::cpp2::Serious>::gen(metadata);
307   func.is_oneway_ref() = false;
308   service.functions_ref()->push_back(std::move(func));
309 }
gen_get200(ThriftMetadata & metadata,ThriftService & service)310 void ServiceMetadata<::cpp2::RaiserSvIf>::gen_get200(ThriftMetadata& metadata, ThriftService& service) {
311   ::apache::thrift::metadata::ThriftFunction func;
312   (void)metadata;
313   func.name_ref() = "get200";
314   auto func_ret_type = std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE);
315   func_ret_type->writeAndGenType(*func.return_type_ref(), metadata);
316   func.is_oneway_ref() = false;
317   service.functions_ref()->push_back(std::move(func));
318 }
gen_get500(ThriftMetadata & metadata,ThriftService & service)319 void ServiceMetadata<::cpp2::RaiserSvIf>::gen_get500(ThriftMetadata& metadata, ThriftService& service) {
320   ::apache::thrift::metadata::ThriftFunction func;
321   (void)metadata;
322   func.name_ref() = "get500";
323   auto func_ret_type = std::make_unique<Primitive>(ThriftPrimitiveType::THRIFT_STRING_TYPE);
324   func_ret_type->writeAndGenType(*func.return_type_ref(), metadata);
325   ::apache::thrift::metadata::ThriftField module_Raiser_get500_f_1;
326   module_Raiser_get500_f_1.id_ref() = 1;
327   module_Raiser_get500_f_1.name_ref() = "f";
328   module_Raiser_get500_f_1.is_optional_ref() = false;
329   auto module_Raiser_get500_f_1_type = std::make_unique<Struct< ::cpp2::Fiery>>("module.Fiery");
330   module_Raiser_get500_f_1_type->writeAndGenType(*module_Raiser_get500_f_1.type_ref(), metadata);
331   func.exceptions_ref()->push_back(std::move(module_Raiser_get500_f_1));
332   ExceptionMetadata< ::cpp2::Fiery>::gen(metadata);
333   ::apache::thrift::metadata::ThriftField module_Raiser_get500_b_2;
334   module_Raiser_get500_b_2.id_ref() = 2;
335   module_Raiser_get500_b_2.name_ref() = "b";
336   module_Raiser_get500_b_2.is_optional_ref() = false;
337   auto module_Raiser_get500_b_2_type = std::make_unique<Typedef>("module.Banal", std::make_unique<Struct< ::cpp2::Banal>>("module.Banal"), std::vector<ThriftConstStruct>{});
338   module_Raiser_get500_b_2_type->writeAndGenType(*module_Raiser_get500_b_2.type_ref(), metadata);
339   func.exceptions_ref()->push_back(std::move(module_Raiser_get500_b_2));
340   ExceptionMetadata< ::cpp2::Banal>::gen(metadata);
341   ::apache::thrift::metadata::ThriftField module_Raiser_get500_s_3;
342   module_Raiser_get500_s_3.id_ref() = 3;
343   module_Raiser_get500_s_3.name_ref() = "s";
344   module_Raiser_get500_s_3.is_optional_ref() = false;
345   auto module_Raiser_get500_s_3_type = std::make_unique<Struct< ::cpp2::Serious>>("module.Serious");
346   module_Raiser_get500_s_3_type->writeAndGenType(*module_Raiser_get500_s_3.type_ref(), metadata);
347   func.exceptions_ref()->push_back(std::move(module_Raiser_get500_s_3));
348   ExceptionMetadata< ::cpp2::Serious>::gen(metadata);
349   func.is_oneway_ref() = false;
350   service.functions_ref()->push_back(std::move(func));
351 }
352 
gen(::apache::thrift::metadata::ThriftServiceMetadataResponse & response)353 void ServiceMetadata<::cpp2::RaiserSvIf>::gen(::apache::thrift::metadata::ThriftServiceMetadataResponse& response) {
354   const ::apache::thrift::metadata::ThriftServiceContextRef* self = genRecurse(*response.metadata_ref(), *response.services_ref());
355   DCHECK(self != nullptr);
356   // TODO(praihan): Remove ThriftServiceContext from response. But in the meantime, we need to fill the field with the result of looking up in ThriftMetadata.
357   ::apache::thrift::metadata::ThriftServiceContext context;
358   context.module_ref() = *self->module_ref();
359   context.service_info_ref() = response.metadata_ref()->services_ref()->at(*self->service_name_ref());
360   response.context_ref() = std::move(context);
361 }
362 
genRecurse(ThriftMetadata & metadata,std::vector<ThriftServiceContextRef> & services)363 const ThriftServiceContextRef* ServiceMetadata<::cpp2::RaiserSvIf>::genRecurse(ThriftMetadata& metadata, std::vector<ThriftServiceContextRef>& services) {
364   (void) metadata;
365   ::apache::thrift::metadata::ThriftService module_Raiser;
366   module_Raiser.name_ref() = "module.Raiser";
367   static const ThriftFunctionGenerator functions[] = {
368     ServiceMetadata<::cpp2::RaiserSvIf>::gen_doBland,
369     ServiceMetadata<::cpp2::RaiserSvIf>::gen_doRaise,
370     ServiceMetadata<::cpp2::RaiserSvIf>::gen_get200,
371     ServiceMetadata<::cpp2::RaiserSvIf>::gen_get500,
372   };
373   for (auto& function_gen : functions) {
374     function_gen(metadata, module_Raiser);
375   }
376   // We need to keep the index around because a reference or iterator could be invalidated.
377   auto selfIndex = services.size();
378   services.emplace_back();
379   ThriftServiceContextRef& context = services[selfIndex];
380   metadata.services_ref()->emplace("module.Raiser", std::move(module_Raiser));
381   context.service_name_ref() = "module.Raiser";
382   ::apache::thrift::metadata::ThriftModuleContext module;
383   module.name_ref() = "module";
384   context.module_ref() = std::move(module);
385   return &context;
386 }
387 } // namespace md
388 } // namespace detail
389 } // namespace thrift
390 } // namespace apache
391