From a0202b9d9b230aaabc003f7c927311a15522bddd Mon Sep 17 00:00:00 2001 From: fgy Date: Wed, 6 Sep 2023 11:39:41 +0800 Subject: [PATCH] feat: struct reuse --- hz/struct_reuse/protobuf/api.proto | 77 ++ hz/struct_reuse/protobuf/hello/hello.proto | 22 + hz/struct_reuse/protobuf_reuse/Makefile | 20 + hz/struct_reuse/protobuf_reuse/go.mod | 3 + .../kitex_gen/api/api.pb.fast.go | 15 + .../protobuf_reuse/kitex_gen/api/api.pb.go | 694 +++++++++++++++ .../kitex_gen/hello/hello.pb.fast.go | 138 +++ .../kitex_gen/hello/hello.pb.go | 215 +++++ .../kitex_gen/hello/helloservice/client.go | 49 ++ .../hello/helloservice/helloservice.go | 212 +++++ .../kitex_gen/hello/helloservice/invoker.go | 24 + .../kitex_gen/hello/helloservice/server.go | 20 + hz/struct_reuse/thrift/hello.thrift | 14 + hz/struct_reuse/thrift_reuse/Makefile | 15 + hz/struct_reuse/thrift_reuse/go.mod | 5 + .../kitex_gen/hello/example/hello.go | 813 ++++++++++++++++++ .../hello/example/helloservice/client.go | 49 ++ .../example/helloservice/helloservice.go | 75 ++ .../hello/example/helloservice/invoker.go | 24 + .../hello/example/helloservice/server.go | 20 + .../kitex_gen/hello/example/k-consts.go | 4 + .../kitex_gen/hello/example/k-hello.go | 550 ++++++++++++ 22 files changed, 3058 insertions(+) create mode 100644 hz/struct_reuse/protobuf/api.proto create mode 100644 hz/struct_reuse/protobuf/hello/hello.proto create mode 100644 hz/struct_reuse/protobuf_reuse/Makefile create mode 100644 hz/struct_reuse/protobuf_reuse/go.mod create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.fast.go create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.go create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.fast.go create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.go create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/client.go create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/helloservice.go create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/invoker.go create mode 100644 hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/server.go create mode 100644 hz/struct_reuse/thrift/hello.thrift create mode 100644 hz/struct_reuse/thrift_reuse/Makefile create mode 100644 hz/struct_reuse/thrift_reuse/go.mod create mode 100644 hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/hello.go create mode 100644 hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/client.go create mode 100644 hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/helloservice.go create mode 100644 hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/invoker.go create mode 100644 hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/server.go create mode 100644 hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-consts.go create mode 100644 hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-hello.go diff --git a/hz/struct_reuse/protobuf/api.proto b/hz/struct_reuse/protobuf/api.proto new file mode 100644 index 00000000..41c86b05 --- /dev/null +++ b/hz/struct_reuse/protobuf/api.proto @@ -0,0 +1,77 @@ +syntax = "proto2"; + +package api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "a/b/c/kitex_gen/api"; + +extend google.protobuf.FieldOptions { + optional string raw_body = 50101; + optional string query = 50102; + optional string header = 50103; + optional string cookie = 50104; + optional string body = 50105; + optional string path = 50106; + optional string vd = 50107; + optional string form = 50108; + optional string js_conv = 50109; + optional string file_name = 50110; + optional string none = 50111; + + // 50131~50160 used to extend field option by hz + optional string form_compatible = 50131; + optional string js_conv_compatible = 50132; + optional string file_name_compatible = 50133; + optional string none_compatible = 50134; + // 50135 is reserved to vt_compatible + // optional FieldRules vt_compatible = 50135; + + optional string go_tag = 51001; +} + +extend google.protobuf.MethodOptions { + optional string get = 50201; + optional string post = 50202; + optional string put = 50203; + optional string delete = 50204; + optional string patch = 50205; + optional string options = 50206; + optional string head = 50207; + optional string any = 50208; + optional string gen_path = 50301; // The path specified by the user when the client code is generated, with a higher priority than api_version + optional string api_version = 50302; // Specify the value of the :version variable in path when the client code is generated + optional string tag = 50303; // rpc tag, can be multiple, separated by commas + optional string name = 50304; // Name of rpc + optional string api_level = 50305; // Interface Level + optional string serializer = 50306; // Serialization method + optional string param = 50307; // Whether client requests take public parameters + optional string baseurl = 50308; // Baseurl used in ttnet routing + optional string handler_path = 50309; // handler_path specifies the path to generate the method + + // 50331~50360 used to extend method option by hz + optional string handler_path_compatible = 50331; // handler_path specifies the path to generate the method + optional string custom = 55556; // deprecated +} + +extend google.protobuf.EnumValueOptions { + optional int32 http_code = 50401; + + // 50431~50460 used to extend enum option by hz +} + +extend google.protobuf.ServiceOptions { + optional string base_domain = 50402; + + // 50731~50760 used to extend service option by hz + optional string base_domain_compatible = 50731; + optional string service_path = 50732; +} + +extend google.protobuf.MessageOptions { + // optional FieldRules msg_vt = 50111; + + optional string reserve = 50830; + // 550831 is reserved to msg_vt_compatible + // optional FieldRules msg_vt_compatible = 50831; +} \ No newline at end of file diff --git a/hz/struct_reuse/protobuf/hello/hello.proto b/hz/struct_reuse/protobuf/hello/hello.proto new file mode 100644 index 00000000..e96b092d --- /dev/null +++ b/hz/struct_reuse/protobuf/hello/hello.proto @@ -0,0 +1,22 @@ +// idl/hello/hello.proto +syntax = "proto3"; // proto2/3 语法均可,推荐 proto3 + +package hello; + +option go_package = "a/b/c/kitex_gen/hello"; + +import "api.proto"; + +message HelloReq { + string Name = 1; +} + +message HelloResp { + string RespBody = 1; +} + +service HelloService { + rpc Method1(HelloReq) returns(HelloResp) { + option (api.get) = "/api/v1"; + } +} \ No newline at end of file diff --git a/hz/struct_reuse/protobuf_reuse/Makefile b/hz/struct_reuse/protobuf_reuse/Makefile new file mode 100644 index 00000000..f82d2968 --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/Makefile @@ -0,0 +1,20 @@ +hz_install: + go install github.com/cloudwego/hertz/cmd/hz@latest + +kitex_install: + go install github.com/cloudwego/kitex/tool/cmd/kitex@latest + +mod_init: + go mod init a/b/c + +kitex_model: + kitex --module=a/b/c -I=../protobuf ../protobuf/hello/hello.proto + +hz_model: + hz model --mod=a/b/c --model_dir=kitex_gen -I=../protobuf --idl=../protobuf/hello/hello.proto + +# 使用 hz_model 去覆盖 kitex_model, +# 注意: +# 1.所有 proto 中 go_package 的定义必须是这种形式 "{GOMOD}/kitex_gen/***" 其中gomod为项目的 go module 名 +# 2. hz 的命令必须加 --model_dir=kitex_gen,才能正确覆盖 kitex_modle +# 3. 目前 hz无法生成 kitex 需要的接口信息,需要进一步对齐 diff --git a/hz/struct_reuse/protobuf_reuse/go.mod b/hz/struct_reuse/protobuf_reuse/go.mod new file mode 100644 index 00000000..cb0e9979 --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/go.mod @@ -0,0 +1,3 @@ +module a/b/c + +go 1.20 diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.fast.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.fast.go new file mode 100644 index 00000000..c41b68fc --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.fast.go @@ -0,0 +1,15 @@ +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package api + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) +var _ = descriptorpb.File_google_protobuf_descriptor_proto diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.go new file mode 100644 index 00000000..b49d260e --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/api/api.pb.go @@ -0,0 +1,694 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.12 +// source: api.proto + +package api + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + descriptorpb "google.golang.org/protobuf/types/descriptorpb" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var file_api_proto_extTypes = []protoimpl.ExtensionInfo{ + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50101, + Name: "api.raw_body", + Tag: "bytes,50101,opt,name=raw_body", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50102, + Name: "api.query", + Tag: "bytes,50102,opt,name=query", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50103, + Name: "api.header", + Tag: "bytes,50103,opt,name=header", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50104, + Name: "api.cookie", + Tag: "bytes,50104,opt,name=cookie", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50105, + Name: "api.body", + Tag: "bytes,50105,opt,name=body", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50106, + Name: "api.path", + Tag: "bytes,50106,opt,name=path", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50107, + Name: "api.vd", + Tag: "bytes,50107,opt,name=vd", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50108, + Name: "api.form", + Tag: "bytes,50108,opt,name=form", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50109, + Name: "api.js_conv", + Tag: "bytes,50109,opt,name=js_conv", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50110, + Name: "api.file_name", + Tag: "bytes,50110,opt,name=file_name", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50111, + Name: "api.none", + Tag: "bytes,50111,opt,name=none", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50131, + Name: "api.form_compatible", + Tag: "bytes,50131,opt,name=form_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50132, + Name: "api.js_conv_compatible", + Tag: "bytes,50132,opt,name=js_conv_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50133, + Name: "api.file_name_compatible", + Tag: "bytes,50133,opt,name=file_name_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50134, + Name: "api.none_compatible", + Tag: "bytes,50134,opt,name=none_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.FieldOptions)(nil), + ExtensionType: (*string)(nil), + Field: 51001, + Name: "api.go_tag", + Tag: "bytes,51001,opt,name=go_tag", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50201, + Name: "api.get", + Tag: "bytes,50201,opt,name=get", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50202, + Name: "api.post", + Tag: "bytes,50202,opt,name=post", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50203, + Name: "api.put", + Tag: "bytes,50203,opt,name=put", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50204, + Name: "api.delete", + Tag: "bytes,50204,opt,name=delete", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50205, + Name: "api.patch", + Tag: "bytes,50205,opt,name=patch", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50206, + Name: "api.options", + Tag: "bytes,50206,opt,name=options", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50207, + Name: "api.head", + Tag: "bytes,50207,opt,name=head", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50208, + Name: "api.any", + Tag: "bytes,50208,opt,name=any", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50301, + Name: "api.gen_path", + Tag: "bytes,50301,opt,name=gen_path", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50302, + Name: "api.api_version", + Tag: "bytes,50302,opt,name=api_version", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50303, + Name: "api.tag", + Tag: "bytes,50303,opt,name=tag", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50304, + Name: "api.name", + Tag: "bytes,50304,opt,name=name", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50305, + Name: "api.api_level", + Tag: "bytes,50305,opt,name=api_level", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50306, + Name: "api.serializer", + Tag: "bytes,50306,opt,name=serializer", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50307, + Name: "api.param", + Tag: "bytes,50307,opt,name=param", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50308, + Name: "api.baseurl", + Tag: "bytes,50308,opt,name=baseurl", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50309, + Name: "api.handler_path", + Tag: "bytes,50309,opt,name=handler_path", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50331, + Name: "api.handler_path_compatible", + Tag: "bytes,50331,opt,name=handler_path_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MethodOptions)(nil), + ExtensionType: (*string)(nil), + Field: 55556, + Name: "api.custom", + Tag: "bytes,55556,opt,name=custom", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.EnumValueOptions)(nil), + ExtensionType: (*int32)(nil), + Field: 50401, + Name: "api.http_code", + Tag: "varint,50401,opt,name=http_code", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50402, + Name: "api.base_domain", + Tag: "bytes,50402,opt,name=base_domain", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50731, + Name: "api.base_domain_compatible", + Tag: "bytes,50731,opt,name=base_domain_compatible", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.ServiceOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50732, + Name: "api.service_path", + Tag: "bytes,50732,opt,name=service_path", + Filename: "api.proto", + }, + { + ExtendedType: (*descriptorpb.MessageOptions)(nil), + ExtensionType: (*string)(nil), + Field: 50830, + Name: "api.reserve", + Tag: "bytes,50830,opt,name=reserve", + Filename: "api.proto", + }, +} + +// Extension fields to descriptorpb.FieldOptions. +var ( + // optional string raw_body = 50101; + E_RawBody = &file_api_proto_extTypes[0] + // optional string query = 50102; + E_Query = &file_api_proto_extTypes[1] + // optional string header = 50103; + E_Header = &file_api_proto_extTypes[2] + // optional string cookie = 50104; + E_Cookie = &file_api_proto_extTypes[3] + // optional string body = 50105; + E_Body = &file_api_proto_extTypes[4] + // optional string path = 50106; + E_Path = &file_api_proto_extTypes[5] + // optional string vd = 50107; + E_Vd = &file_api_proto_extTypes[6] + // optional string form = 50108; + E_Form = &file_api_proto_extTypes[7] + // optional string js_conv = 50109; + E_JsConv = &file_api_proto_extTypes[8] + // optional string file_name = 50110; + E_FileName = &file_api_proto_extTypes[9] + // optional string none = 50111; + E_None = &file_api_proto_extTypes[10] + // 50131~50160 used to extend field option by hz + // + // optional string form_compatible = 50131; + E_FormCompatible = &file_api_proto_extTypes[11] + // optional string js_conv_compatible = 50132; + E_JsConvCompatible = &file_api_proto_extTypes[12] + // optional string file_name_compatible = 50133; + E_FileNameCompatible = &file_api_proto_extTypes[13] + // optional string none_compatible = 50134; + E_NoneCompatible = &file_api_proto_extTypes[14] + // optional string go_tag = 51001; + E_GoTag = &file_api_proto_extTypes[15] +) + +// Extension fields to descriptorpb.MethodOptions. +var ( + // optional string get = 50201; + E_Get = &file_api_proto_extTypes[16] + // optional string post = 50202; + E_Post = &file_api_proto_extTypes[17] + // optional string put = 50203; + E_Put = &file_api_proto_extTypes[18] + // optional string delete = 50204; + E_Delete = &file_api_proto_extTypes[19] + // optional string patch = 50205; + E_Patch = &file_api_proto_extTypes[20] + // optional string options = 50206; + E_Options = &file_api_proto_extTypes[21] + // optional string head = 50207; + E_Head = &file_api_proto_extTypes[22] + // optional string any = 50208; + E_Any = &file_api_proto_extTypes[23] + // optional string gen_path = 50301; + E_GenPath = &file_api_proto_extTypes[24] // The path specified by the user when the client code is generated, with a higher priority than api_version + // optional string api_version = 50302; + E_ApiVersion = &file_api_proto_extTypes[25] // Specify the value of the :version variable in path when the client code is generated + // optional string tag = 50303; + E_Tag = &file_api_proto_extTypes[26] // rpc tag, can be multiple, separated by commas + // optional string name = 50304; + E_Name = &file_api_proto_extTypes[27] // Name of rpc + // optional string api_level = 50305; + E_ApiLevel = &file_api_proto_extTypes[28] // Interface Level + // optional string serializer = 50306; + E_Serializer = &file_api_proto_extTypes[29] // Serialization method + // optional string param = 50307; + E_Param = &file_api_proto_extTypes[30] // Whether client requests take public parameters + // optional string baseurl = 50308; + E_Baseurl = &file_api_proto_extTypes[31] // Baseurl used in ttnet routing + // optional string handler_path = 50309; + E_HandlerPath = &file_api_proto_extTypes[32] // handler_path specifies the path to generate the method + // 50331~50360 used to extend method option by hz + // + // optional string handler_path_compatible = 50331; + E_HandlerPathCompatible = &file_api_proto_extTypes[33] // handler_path specifies the path to generate the method + // optional string custom = 55556; + E_Custom = &file_api_proto_extTypes[34] // deprecated +) + +// Extension fields to descriptorpb.EnumValueOptions. +var ( + // optional int32 http_code = 50401; + E_HttpCode = &file_api_proto_extTypes[35] +) + +// Extension fields to descriptorpb.ServiceOptions. +var ( + // optional string base_domain = 50402; + E_BaseDomain = &file_api_proto_extTypes[36] + // 50731~50760 used to extend service option by hz + // + // optional string base_domain_compatible = 50731; + E_BaseDomainCompatible = &file_api_proto_extTypes[37] + // optional string service_path = 50732; + E_ServicePath = &file_api_proto_extTypes[38] +) + +// Extension fields to descriptorpb.MessageOptions. +var ( + // optional string reserve = 50830; + E_Reserve = &file_api_proto_extTypes[39] +) + +var File_api_proto protoreflect.FileDescriptor + +var file_api_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, + 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x3a, 0x3a, 0x0a, 0x08, 0x72, 0x61, 0x77, 0x5f, 0x62, 0x6f, 0x64, 0x79, 0x12, 0x1d, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb5, 0x87, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x61, 0x77, 0x42, 0x6f, 0x64, 0x79, 0x3a, 0x35, + 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb6, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x71, 0x75, 0x65, 0x72, 0x79, 0x3a, 0x37, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, + 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb7, + 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x3a, 0x37, + 0x0a, 0x06, 0x63, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb8, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x63, 0x6f, 0x6f, 0x6b, 0x69, 0x65, 0x3a, 0x33, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x12, + 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xb9, + 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x3a, 0x33, 0x0a, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xba, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x3a, 0x2f, 0x0a, 0x02, 0x76, 0x64, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbb, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x76, 0x64, 0x3a, 0x33, 0x0a, 0x04, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbc, 0x87, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x66, 0x6f, 0x72, 0x6d, 0x3a, 0x38, 0x0a, 0x07, 0x6a, 0x73, 0x5f, 0x63, 0x6f, + 0x6e, 0x76, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0xbd, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6a, 0x73, 0x43, 0x6f, 0x6e, + 0x76, 0x3a, 0x3c, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1d, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbe, 0x87, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x3a, + 0x33, 0x0a, 0x04, 0x6e, 0x6f, 0x6e, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xbf, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x6f, 0x6e, 0x65, 0x3a, 0x48, 0x0a, 0x0f, 0x66, 0x6f, 0x72, 0x6d, 0x5f, 0x63, 0x6f, 0x6d, + 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd3, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, + 0x66, 0x6f, 0x72, 0x6d, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x4d, + 0x0a, 0x12, 0x6a, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, + 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xd4, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x6a, 0x73, 0x43, + 0x6f, 0x6e, 0x76, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x51, 0x0a, + 0x14, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, + 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd5, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x66, 0x69, + 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, + 0x3a, 0x48, 0x0a, 0x0f, 0x6e, 0x6f, 0x6e, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, + 0x62, 0x6c, 0x65, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0xd6, 0x87, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6e, 0x6f, 0x6e, 0x65, + 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x36, 0x0a, 0x06, 0x67, 0x6f, + 0x5f, 0x74, 0x61, 0x67, 0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0xb9, 0x8e, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x67, 0x6f, 0x54, + 0x61, 0x67, 0x3a, 0x32, 0x0a, 0x03, 0x67, 0x65, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x99, 0x88, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x67, 0x65, 0x74, 0x3a, 0x34, 0x0a, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x12, 0x1e, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9a, + 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x6f, 0x73, 0x74, 0x3a, 0x32, 0x0a, 0x03, + 0x70, 0x75, 0x74, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x9b, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x70, 0x75, 0x74, + 0x3a, 0x38, 0x0a, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9c, 0x88, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x3a, 0x36, 0x0a, 0x05, 0x70, 0x61, + 0x74, 0x63, 0x68, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x9d, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x3a, 0x3a, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1e, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9e, 0x88, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3a, 0x34, + 0x0a, 0x04, 0x68, 0x65, 0x61, 0x64, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9f, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x68, 0x65, 0x61, 0x64, 0x3a, 0x32, 0x0a, 0x03, 0x61, 0x6e, 0x79, 0x12, 0x1e, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xa0, 0x88, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x6e, 0x79, 0x3a, 0x3b, 0x0a, 0x08, 0x67, 0x65, 0x6e, 0x5f, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xfd, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x65, + 0x6e, 0x50, 0x61, 0x74, 0x68, 0x3a, 0x41, 0x0a, 0x0b, 0x61, 0x70, 0x69, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xfe, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, + 0x69, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x32, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0xff, 0x88, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x3a, 0x34, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x80, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x3a, 0x3d, 0x0a, 0x09, 0x61, 0x70, 0x69, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x81, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x70, 0x69, 0x4c, 0x65, 0x76, 0x65, + 0x6c, 0x3a, 0x40, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x72, 0x12, + 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, + 0x82, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x69, + 0x7a, 0x65, 0x72, 0x3a, 0x36, 0x0a, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x12, 0x1e, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x83, 0x89, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x3a, 0x3a, 0x0a, 0x07, 0x62, + 0x61, 0x73, 0x65, 0x75, 0x72, 0x6c, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, + 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x84, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x62, 0x61, 0x73, 0x65, 0x75, 0x72, 0x6c, 0x3a, 0x43, 0x0a, 0x0c, 0x68, 0x61, 0x6e, 0x64, 0x6c, + 0x65, 0x72, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x85, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x50, 0x61, 0x74, 0x68, 0x3a, 0x58, 0x0a, 0x17, + 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x5f, 0x63, 0x6f, 0x6d, + 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, + 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x9b, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x15, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x50, 0x61, 0x74, 0x68, 0x43, 0x6f, 0x6d, 0x70, + 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, 0x38, 0x0a, 0x06, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, + 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x84, 0xb2, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, + 0x3a, 0x40, 0x0a, 0x09, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0xe1, 0x89, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x68, 0x74, 0x74, 0x70, 0x43, 0x6f, + 0x64, 0x65, 0x3a, 0x42, 0x0a, 0x0b, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0xe2, 0x89, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x61, 0x73, 0x65, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x3a, 0x57, 0x0a, 0x16, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, + 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0xab, 0x8c, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x62, 0x61, 0x73, 0x65, 0x44, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x6c, 0x65, 0x3a, + 0x44, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x12, + 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0xac, 0x8c, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x50, 0x61, 0x74, 0x68, 0x3a, 0x3b, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x8e, 0x8d, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x42, 0x15, 0x5a, 0x13, 0x61, 0x2f, 0x62, 0x2f, 0x63, 0x2f, 0x6b, 0x69, 0x74, 0x65, + 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, +} + +var file_api_proto_goTypes = []interface{}{ + (*descriptorpb.FieldOptions)(nil), // 0: google.protobuf.FieldOptions + (*descriptorpb.MethodOptions)(nil), // 1: google.protobuf.MethodOptions + (*descriptorpb.EnumValueOptions)(nil), // 2: google.protobuf.EnumValueOptions + (*descriptorpb.ServiceOptions)(nil), // 3: google.protobuf.ServiceOptions + (*descriptorpb.MessageOptions)(nil), // 4: google.protobuf.MessageOptions +} +var file_api_proto_depIdxs = []int32{ + 0, // 0: api.raw_body:extendee -> google.protobuf.FieldOptions + 0, // 1: api.query:extendee -> google.protobuf.FieldOptions + 0, // 2: api.header:extendee -> google.protobuf.FieldOptions + 0, // 3: api.cookie:extendee -> google.protobuf.FieldOptions + 0, // 4: api.body:extendee -> google.protobuf.FieldOptions + 0, // 5: api.path:extendee -> google.protobuf.FieldOptions + 0, // 6: api.vd:extendee -> google.protobuf.FieldOptions + 0, // 7: api.form:extendee -> google.protobuf.FieldOptions + 0, // 8: api.js_conv:extendee -> google.protobuf.FieldOptions + 0, // 9: api.file_name:extendee -> google.protobuf.FieldOptions + 0, // 10: api.none:extendee -> google.protobuf.FieldOptions + 0, // 11: api.form_compatible:extendee -> google.protobuf.FieldOptions + 0, // 12: api.js_conv_compatible:extendee -> google.protobuf.FieldOptions + 0, // 13: api.file_name_compatible:extendee -> google.protobuf.FieldOptions + 0, // 14: api.none_compatible:extendee -> google.protobuf.FieldOptions + 0, // 15: api.go_tag:extendee -> google.protobuf.FieldOptions + 1, // 16: api.get:extendee -> google.protobuf.MethodOptions + 1, // 17: api.post:extendee -> google.protobuf.MethodOptions + 1, // 18: api.put:extendee -> google.protobuf.MethodOptions + 1, // 19: api.delete:extendee -> google.protobuf.MethodOptions + 1, // 20: api.patch:extendee -> google.protobuf.MethodOptions + 1, // 21: api.options:extendee -> google.protobuf.MethodOptions + 1, // 22: api.head:extendee -> google.protobuf.MethodOptions + 1, // 23: api.any:extendee -> google.protobuf.MethodOptions + 1, // 24: api.gen_path:extendee -> google.protobuf.MethodOptions + 1, // 25: api.api_version:extendee -> google.protobuf.MethodOptions + 1, // 26: api.tag:extendee -> google.protobuf.MethodOptions + 1, // 27: api.name:extendee -> google.protobuf.MethodOptions + 1, // 28: api.api_level:extendee -> google.protobuf.MethodOptions + 1, // 29: api.serializer:extendee -> google.protobuf.MethodOptions + 1, // 30: api.param:extendee -> google.protobuf.MethodOptions + 1, // 31: api.baseurl:extendee -> google.protobuf.MethodOptions + 1, // 32: api.handler_path:extendee -> google.protobuf.MethodOptions + 1, // 33: api.handler_path_compatible:extendee -> google.protobuf.MethodOptions + 1, // 34: api.custom:extendee -> google.protobuf.MethodOptions + 2, // 35: api.http_code:extendee -> google.protobuf.EnumValueOptions + 3, // 36: api.base_domain:extendee -> google.protobuf.ServiceOptions + 3, // 37: api.base_domain_compatible:extendee -> google.protobuf.ServiceOptions + 3, // 38: api.service_path:extendee -> google.protobuf.ServiceOptions + 4, // 39: api.reserve:extendee -> google.protobuf.MessageOptions + 40, // [40:40] is the sub-list for method output_type + 40, // [40:40] is the sub-list for method input_type + 40, // [40:40] is the sub-list for extension type_name + 0, // [0:40] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_api_proto_init() } +func file_api_proto_init() { + if File_api_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_api_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 40, + NumServices: 0, + }, + GoTypes: file_api_proto_goTypes, + DependencyIndexes: file_api_proto_depIdxs, + ExtensionInfos: file_api_proto_extTypes, + }.Build() + File_api_proto = out.File + file_api_proto_rawDesc = nil + file_api_proto_goTypes = nil + file_api_proto_depIdxs = nil +} diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.fast.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.fast.go new file mode 100644 index 00000000..3ca8543a --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.fast.go @@ -0,0 +1,138 @@ +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package hello + +import ( + api "a/b/c/kitex_gen/api" + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *HelloReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_HelloReq[number], err) +} + +func (x *HelloReq) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Name, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *HelloResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_HelloResp[number], err) +} + +func (x *HelloResp) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.RespBody, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *HelloReq) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *HelloReq) fastWriteField1(buf []byte) (offset int) { + if x.Name == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetName()) + return offset +} + +func (x *HelloResp) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *HelloResp) fastWriteField1(buf []byte) (offset int) { + if x.RespBody == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetRespBody()) + return offset +} + +func (x *HelloReq) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *HelloReq) sizeField1() (n int) { + if x.Name == "" { + return n + } + n += fastpb.SizeString(1, x.GetName()) + return n +} + +func (x *HelloResp) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *HelloResp) sizeField1() (n int) { + if x.RespBody == "" { + return n + } + n += fastpb.SizeString(1, x.GetRespBody()) + return n +} + +var fieldIDToName_HelloReq = map[int32]string{ + 1: "Name", +} + +var fieldIDToName_HelloResp = map[int32]string{ + 1: "RespBody", +} + +var _ = api.File_api_proto diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.go new file mode 100644 index 00000000..563c91a9 --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/hello.pb.go @@ -0,0 +1,215 @@ +// idl/hello/hello.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.12 +// source: hello.proto + +package hello + +import ( + _ "a/b/c/kitex_gen/api" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type HelloReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty" form:"Name" query:"Name"` +} + +func (x *HelloReq) Reset() { + *x = HelloReq{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloReq) ProtoMessage() {} + +func (x *HelloReq) ProtoReflect() protoreflect.Message { + mi := &file_hello_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloReq.ProtoReflect.Descriptor instead. +func (*HelloReq) Descriptor() ([]byte, []int) { + return file_hello_proto_rawDescGZIP(), []int{0} +} + +func (x *HelloReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type HelloResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RespBody string `protobuf:"bytes,1,opt,name=RespBody,proto3" json:"RespBody,omitempty" form:"RespBody" query:"RespBody"` +} + +func (x *HelloResp) Reset() { + *x = HelloResp{} + if protoimpl.UnsafeEnabled { + mi := &file_hello_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloResp) ProtoMessage() {} + +func (x *HelloResp) ProtoReflect() protoreflect.Message { + mi := &file_hello_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloResp.ProtoReflect.Descriptor instead. +func (*HelloResp) Descriptor() ([]byte, []int) { + return file_hello_proto_rawDescGZIP(), []int{1} +} + +func (x *HelloResp) GetRespBody() string { + if x != nil { + return x.RespBody + } + return "" +} + +var File_hello_proto protoreflect.FileDescriptor + +var file_hello_proto_rawDesc = []byte{ + 0x0a, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x68, + 0x65, 0x6c, 0x6c, 0x6f, 0x1a, 0x09, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x1e, 0x0a, 0x08, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, + 0x27, 0x0a, 0x09, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, + 0x52, 0x65, 0x73, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x52, 0x65, 0x73, 0x70, 0x42, 0x6f, 0x64, 0x79, 0x32, 0x49, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x07, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x31, 0x12, 0x0f, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x2e, 0x48, 0x65, 0x6c, + 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x22, 0x0b, 0xca, 0xc1, 0x18, 0x07, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x76, 0x31, 0x42, 0x17, 0x5a, 0x15, 0x61, 0x2f, 0x62, 0x2f, 0x63, 0x2f, 0x6b, 0x69, 0x74, + 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_hello_proto_rawDescOnce sync.Once + file_hello_proto_rawDescData = file_hello_proto_rawDesc +) + +func file_hello_proto_rawDescGZIP() []byte { + file_hello_proto_rawDescOnce.Do(func() { + file_hello_proto_rawDescData = protoimpl.X.CompressGZIP(file_hello_proto_rawDescData) + }) + return file_hello_proto_rawDescData +} + +var file_hello_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_hello_proto_goTypes = []interface{}{ + (*HelloReq)(nil), // 0: hello.HelloReq + (*HelloResp)(nil), // 1: hello.HelloResp +} +var file_hello_proto_depIdxs = []int32{ + 0, // 0: hello.HelloService.Method1:input_type -> hello.HelloReq + 1, // 1: hello.HelloService.Method1:output_type -> hello.HelloResp + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_hello_proto_init() } +func file_hello_proto_init() { + if File_hello_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_hello_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hello_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_hello_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_hello_proto_goTypes, + DependencyIndexes: file_hello_proto_depIdxs, + MessageInfos: file_hello_proto_msgTypes, + }.Build() + File_hello_proto = out.File + file_hello_proto_rawDesc = nil + file_hello_proto_goTypes = nil + file_hello_proto_depIdxs = nil +} diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/client.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/client.go new file mode 100644 index 00000000..640d4504 --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. + +package helloservice + +import ( + hello "a/b/c/kitex_gen/hello" + "context" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Method1(ctx context.Context, Req *hello.HelloReq, callOptions ...callopt.Option) (r *hello.HelloResp, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kHelloServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kHelloServiceClient struct { + *kClient +} + +func (p *kHelloServiceClient) Method1(ctx context.Context, Req *hello.HelloReq, callOptions ...callopt.Option) (r *hello.HelloResp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Method1(ctx, Req) +} diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/helloservice.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/helloservice.go new file mode 100644 index 00000000..3442546d --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/helloservice.go @@ -0,0 +1,212 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. + +package helloservice + +import ( + hello "a/b/c/kitex_gen/hello" + "context" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" + proto "google.golang.org/protobuf/proto" +) + +func serviceInfo() *kitex.ServiceInfo { + return helloServiceServiceInfo +} + +var helloServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "HelloService" + handlerType := (*hello.HelloService)(nil) + methods := map[string]kitex.MethodInfo{ + "Method1": kitex.NewMethodInfo(method1Handler, newMethod1Args, newMethod1Result, false), + } + extra := map[string]interface{}{ + "PackageName": "hello", + "ServiceFilePath": "", + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Protobuf, + KiteXGenVersion: "v0.7.1", + Extra: extra, + } + return svcInfo +} + +func method1Handler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(hello.HelloReq) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(hello.HelloService).Method1(ctx, req) + if err != nil { + return err + } + if err := st.SendMsg(resp); err != nil { + return err + } + case *Method1Args: + success, err := handler.(hello.HelloService).Method1(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*Method1Result) + realResult.Success = success + } + return nil +} +func newMethod1Args() interface{} { + return &Method1Args{} +} + +func newMethod1Result() interface{} { + return &Method1Result{} +} + +type Method1Args struct { + Req *hello.HelloReq +} + +func (p *Method1Args) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(hello.HelloReq) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *Method1Args) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *Method1Args) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *Method1Args) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *Method1Args) Unmarshal(in []byte) error { + msg := new(hello.HelloReq) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var Method1Args_Req_DEFAULT *hello.HelloReq + +func (p *Method1Args) GetReq() *hello.HelloReq { + if !p.IsSetReq() { + return Method1Args_Req_DEFAULT + } + return p.Req +} + +func (p *Method1Args) IsSetReq() bool { + return p.Req != nil +} + +func (p *Method1Args) GetFirstArgument() interface{} { + return p.Req +} + +type Method1Result struct { + Success *hello.HelloResp +} + +var Method1Result_Success_DEFAULT *hello.HelloResp + +func (p *Method1Result) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(hello.HelloResp) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *Method1Result) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *Method1Result) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *Method1Result) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *Method1Result) Unmarshal(in []byte) error { + msg := new(hello.HelloResp) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *Method1Result) GetSuccess() *hello.HelloResp { + if !p.IsSetSuccess() { + return Method1Result_Success_DEFAULT + } + return p.Success +} + +func (p *Method1Result) SetSuccess(x interface{}) { + p.Success = x.(*hello.HelloResp) +} + +func (p *Method1Result) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *Method1Result) GetResult() interface{} { + return p.Success +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Method1(ctx context.Context, Req *hello.HelloReq) (r *hello.HelloResp, err error) { + var _args Method1Args + _args.Req = Req + var _result Method1Result + if err = p.c.Call(ctx, "Method1", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/invoker.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/invoker.go new file mode 100644 index 00000000..b1a5d0b0 --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. + +package helloservice + +import ( + hello "a/b/c/kitex_gen/hello" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler hello.HelloService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/server.go b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/server.go new file mode 100644 index 00000000..3c8d95b3 --- /dev/null +++ b/hz/struct_reuse/protobuf_reuse/kitex_gen/hello/helloservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. +package helloservice + +import ( + hello "a/b/c/kitex_gen/hello" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler hello.HelloService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/hz/struct_reuse/thrift/hello.thrift b/hz/struct_reuse/thrift/hello.thrift new file mode 100644 index 00000000..811ae957 --- /dev/null +++ b/hz/struct_reuse/thrift/hello.thrift @@ -0,0 +1,14 @@ +namespace go hello.example + +struct HelloReq { + 1: string Name (api.query="name"); +} + +struct HelloResp { + 1: string RespBody; +} + + +service HelloService { + HelloResp HelloMethod(1: HelloReq request) (api.get="/hello"); +} \ No newline at end of file diff --git a/hz/struct_reuse/thrift_reuse/Makefile b/hz/struct_reuse/thrift_reuse/Makefile new file mode 100644 index 00000000..054ae0c4 --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/Makefile @@ -0,0 +1,15 @@ +hz_install: + go install github.com/cloudwego/hertz/cmd/hz@latest + +kitex_install: + go install github.com/cloudwego/kitex/tool/cmd/kitex@latest + +mod_init: + go mod init a/b/c + +kitex_model: + kitex --module=a/b/c ../thrift/hello.thrift +hz_model: + hz model --mod=a/b/c --model_dir=kitex_gen -t=ignore_initialisms -t=gen_setter -t=gen_deep_equal -t=compatible_names -t=frugal_tag --idl=../thrift/hello.thrift + +# 以上使用 hz_model 覆盖 kitex_model, 从而可以生成相同的结构体,也可以进而使用 hz 的 new/update 命令和 kitex 的 service 选项,创建服务代码。 \ No newline at end of file diff --git a/hz/struct_reuse/thrift_reuse/go.mod b/hz/struct_reuse/thrift_reuse/go.mod new file mode 100644 index 00000000..ec4142b9 --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/go.mod @@ -0,0 +1,5 @@ +module a/b/c + +go 1.20 + +replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 diff --git a/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/hello.go b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/hello.go new file mode 100644 index 00000000..8eecdb4e --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/hello.go @@ -0,0 +1,813 @@ +// Code generated by thriftgo (0.3.2). DO NOT EDIT. + +package example + +import ( + "context" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "strings" +) + +type HelloReq struct { + Name string `thrift:"Name,1" frugal:"1,default,string" json:"Name" query:"name"` +} + +func NewHelloReq() *HelloReq { + return &HelloReq{} +} + +func (p *HelloReq) InitDefault() { + *p = HelloReq{} +} + +func (p *HelloReq) GetName() (v string) { + return p.Name +} +func (p *HelloReq) SetName(val string) { + p.Name = val +} + +var fieldIDToName_HelloReq = map[int16]string{ + 1: "Name", +} + +func (p *HelloReq) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloReq[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloReq) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Name = v + } + return nil +} + +func (p *HelloReq) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloReq"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloReq) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Name", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Name); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *HelloReq) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloReq(%+v)", *p) +} + +func (p *HelloReq) DeepEqual(ano *HelloReq) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Name) { + return false + } + return true +} + +func (p *HelloReq) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Name, src) != 0 { + return false + } + return true +} + +type HelloResp struct { + RespBody string `thrift:"RespBody,1" frugal:"1,default,string" form:"RespBody" json:"RespBody" query:"RespBody"` +} + +func NewHelloResp() *HelloResp { + return &HelloResp{} +} + +func (p *HelloResp) InitDefault() { + *p = HelloResp{} +} + +func (p *HelloResp) GetRespBody() (v string) { + return p.RespBody +} +func (p *HelloResp) SetRespBody(val string) { + p.RespBody = val +} + +var fieldIDToName_HelloResp = map[int16]string{ + 1: "RespBody", +} + +func (p *HelloResp) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloResp[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloResp) ReadField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.RespBody = v + } + return nil +} + +func (p *HelloResp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloResp"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloResp) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("RespBody", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.RespBody); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *HelloResp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloResp(%+v)", *p) +} + +func (p *HelloResp) DeepEqual(ano *HelloResp) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.RespBody) { + return false + } + return true +} + +func (p *HelloResp) Field1DeepEqual(src string) bool { + + if strings.Compare(p.RespBody, src) != 0 { + return false + } + return true +} + +type HelloService interface { + HelloMethod(ctx context.Context, request *HelloReq) (r *HelloResp, err error) +} + +type HelloServiceClient struct { + c thrift.TClient +} + +func NewHelloServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *HelloServiceClient { + return &HelloServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewHelloServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *HelloServiceClient { + return &HelloServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewHelloServiceClient(c thrift.TClient) *HelloServiceClient { + return &HelloServiceClient{ + c: c, + } +} + +func (p *HelloServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *HelloServiceClient) HelloMethod(ctx context.Context, request *HelloReq) (r *HelloResp, err error) { + var _args HelloServiceHelloMethodArgs + _args.Request = request + var _result HelloServiceHelloMethodResult + if err = p.Client_().Call(ctx, "HelloMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type HelloServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler HelloService +} + +func (p *HelloServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *HelloServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *HelloServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewHelloServiceProcessor(handler HelloService) *HelloServiceProcessor { + self := &HelloServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("HelloMethod", &helloServiceProcessorHelloMethod{handler: handler}) + return self +} +func (p *HelloServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type helloServiceProcessorHelloMethod struct { + handler HelloService +} + +func (p *helloServiceProcessorHelloMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := HelloServiceHelloMethodArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("HelloMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := HelloServiceHelloMethodResult{} + var retval *HelloResp + if retval, err2 = p.handler.HelloMethod(ctx, args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing HelloMethod: "+err2.Error()) + oprot.WriteMessageBegin("HelloMethod", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("HelloMethod", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type HelloServiceHelloMethodArgs struct { + Request *HelloReq `thrift:"request,1" frugal:"1,default,HelloReq"` +} + +func NewHelloServiceHelloMethodArgs() *HelloServiceHelloMethodArgs { + return &HelloServiceHelloMethodArgs{} +} + +func (p *HelloServiceHelloMethodArgs) InitDefault() { + *p = HelloServiceHelloMethodArgs{} +} + +var HelloServiceHelloMethodArgs_Request_DEFAULT *HelloReq + +func (p *HelloServiceHelloMethodArgs) GetRequest() (v *HelloReq) { + if !p.IsSetRequest() { + return HelloServiceHelloMethodArgs_Request_DEFAULT + } + return p.Request +} +func (p *HelloServiceHelloMethodArgs) SetRequest(val *HelloReq) { + p.Request = val +} + +var fieldIDToName_HelloServiceHelloMethodArgs = map[int16]string{ + 1: "request", +} + +func (p *HelloServiceHelloMethodArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *HelloServiceHelloMethodArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) ReadField1(iprot thrift.TProtocol) error { + p.Request = NewHelloReq() + if err := p.Request.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *HelloServiceHelloMethodArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloMethod_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Request.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloServiceHelloMethodArgs(%+v)", *p) +} + +func (p *HelloServiceHelloMethodArgs) DeepEqual(ano *HelloServiceHelloMethodArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Request) { + return false + } + return true +} + +func (p *HelloServiceHelloMethodArgs) Field1DeepEqual(src *HelloReq) bool { + + if !p.Request.DeepEqual(src) { + return false + } + return true +} + +type HelloServiceHelloMethodResult struct { + Success *HelloResp `thrift:"success,0,optional" frugal:"0,optional,HelloResp"` +} + +func NewHelloServiceHelloMethodResult() *HelloServiceHelloMethodResult { + return &HelloServiceHelloMethodResult{} +} + +func (p *HelloServiceHelloMethodResult) InitDefault() { + *p = HelloServiceHelloMethodResult{} +} + +var HelloServiceHelloMethodResult_Success_DEFAULT *HelloResp + +func (p *HelloServiceHelloMethodResult) GetSuccess() (v *HelloResp) { + if !p.IsSetSuccess() { + return HelloServiceHelloMethodResult_Success_DEFAULT + } + return p.Success +} +func (p *HelloServiceHelloMethodResult) SetSuccess(x interface{}) { + p.Success = x.(*HelloResp) +} + +var fieldIDToName_HelloServiceHelloMethodResult = map[int16]string{ + 0: "success", +} + +func (p *HelloServiceHelloMethodResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *HelloServiceHelloMethodResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else { + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewHelloResp() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *HelloServiceHelloMethodResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("HelloMethod_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloServiceHelloMethodResult(%+v)", *p) +} + +func (p *HelloServiceHelloMethodResult) DeepEqual(ano *HelloServiceHelloMethodResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *HelloServiceHelloMethodResult) Field0DeepEqual(src *HelloResp) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/client.go b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/client.go new file mode 100644 index 00000000..4841ce1f --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. + +package helloservice + +import ( + example "a/b/c/kitex_gen/hello/example" + "context" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + HelloMethod(ctx context.Context, request *example.HelloReq, callOptions ...callopt.Option) (r *example.HelloResp, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kHelloServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kHelloServiceClient struct { + *kClient +} + +func (p *kHelloServiceClient) HelloMethod(ctx context.Context, request *example.HelloReq, callOptions ...callopt.Option) (r *example.HelloResp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.HelloMethod(ctx, request) +} diff --git a/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/helloservice.go b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/helloservice.go new file mode 100644 index 00000000..b6957fc4 --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/helloservice.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. + +package helloservice + +import ( + example "a/b/c/kitex_gen/hello/example" + "context" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return helloServiceServiceInfo +} + +var helloServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "HelloService" + handlerType := (*example.HelloService)(nil) + methods := map[string]kitex.MethodInfo{ + "HelloMethod": kitex.NewMethodInfo(helloMethodHandler, newHelloServiceHelloMethodArgs, newHelloServiceHelloMethodResult, false), + } + extra := map[string]interface{}{ + "PackageName": "example", + "ServiceFilePath": "../thrift/hello.thrift", + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.7.1", + Extra: extra, + } + return svcInfo +} + +func helloMethodHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*example.HelloServiceHelloMethodArgs) + realResult := result.(*example.HelloServiceHelloMethodResult) + success, err := handler.(example.HelloService).HelloMethod(ctx, realArg.Request) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newHelloServiceHelloMethodArgs() interface{} { + return example.NewHelloServiceHelloMethodArgs() +} + +func newHelloServiceHelloMethodResult() interface{} { + return example.NewHelloServiceHelloMethodResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) HelloMethod(ctx context.Context, request *example.HelloReq) (r *example.HelloResp, err error) { + var _args example.HelloServiceHelloMethodArgs + _args.Request = request + var _result example.HelloServiceHelloMethodResult + if err = p.c.Call(ctx, "HelloMethod", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/invoker.go b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/invoker.go new file mode 100644 index 00000000..9f15a7f2 --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. + +package helloservice + +import ( + example "a/b/c/kitex_gen/hello/example" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler example.HelloService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/server.go b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/server.go new file mode 100644 index 00000000..6c167173 --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/helloservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. +package helloservice + +import ( + example "a/b/c/kitex_gen/hello/example" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler example.HelloService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-consts.go b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-consts.go new file mode 100644 index 00000000..06e77a2b --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-consts.go @@ -0,0 +1,4 @@ +package example + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-hello.go b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-hello.go new file mode 100644 index 00000000..3fc1243e --- /dev/null +++ b/hz/struct_reuse/thrift_reuse/kitex_gen/hello/example/k-hello.go @@ -0,0 +1,550 @@ +// Code generated by Kitex v0.7.1. DO NOT EDIT. + +package example + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *HelloReq) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloReq[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloReq) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Name = v + + } + return offset, nil +} + +// for compatibility +func (p *HelloReq) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloReq) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloReq") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloReq) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloReq") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "Name", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Name) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *HelloReq) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("Name", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Name) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *HelloResp) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloResp[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloResp) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.RespBody = v + + } + return offset, nil +} + +// for compatibility +func (p *HelloResp) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloResp") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloResp) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloResp") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "RespBody", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.RespBody) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *HelloResp) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("RespBody", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.RespBody) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *HelloServiceHelloMethodArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewHelloReq() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Request = tmp + return offset, nil +} + +// for compatibility +func (p *HelloServiceHelloMethodArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloServiceHelloMethodArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloMethod_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloServiceHelloMethodArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloMethod_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloServiceHelloMethodArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "request", thrift.STRUCT, 1) + offset += p.Request.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *HelloServiceHelloMethodArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("request", thrift.STRUCT, 1) + l += p.Request.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *HelloServiceHelloMethodResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_HelloServiceHelloMethodResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *HelloServiceHelloMethodResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewHelloResp() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *HelloServiceHelloMethodResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *HelloServiceHelloMethodResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "HelloMethod_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *HelloServiceHelloMethodResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("HelloMethod_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *HelloServiceHelloMethodResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *HelloServiceHelloMethodResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *HelloServiceHelloMethodArgs) GetFirstArgument() interface{} { + return p.Request +} + +func (p *HelloServiceHelloMethodResult) GetResult() interface{} { + return p.Success +}