diff --git a/api/generate.sh b/api/generate.sh index 8b3720359..58fcf019a 100755 --- a/api/generate.sh +++ b/api/generate.sh @@ -1,4 +1,4 @@ export GO111MODULE="on" export GOPROXY="http://goproxy.io" -go get -u github.com/dubbogo/tools/cmd/protoc-gen-triple -protoc -I . samples_api.proto --triple_out=plugins=triple:. \ No newline at end of file +go get -u github.com/dubbogo/tools/cmd/protoc-gen-go-triple +protoc --go_out=. --go-triple_out=. samples_api.proto \ No newline at end of file diff --git a/api/samples_api.pb.go b/api/samples_api.pb.go index e3201836a..2c1449e25 100644 --- a/api/samples_api.pb.go +++ b/api/samples_api.pb.go @@ -16,339 +16,246 @@ */ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.14.0 // source: samples_api.proto package api import ( - context "context" - fmt "fmt" - math "math" + reflect "reflect" + sync "sync" ) import ( - "dubbo.apache.org/dubbo-go/v3/protocol" - dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" - - "github.com/dubbogo/triple/pkg/common" - tripleConstant "github.com/dubbogo/triple/pkg/common/constant" - dubbo3 "github.com/dubbogo/triple/pkg/triple" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf +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) +) -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 // The request message containing the user's name. type HelloRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *HelloRequest) Reset() { *m = HelloRequest{} } -func (m *HelloRequest) String() string { return proto.CompactTextString(m) } -func (*HelloRequest) ProtoMessage() {} -func (*HelloRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_67d196fe99e714eb, []int{0} + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } -func (m *HelloRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HelloRequest.Unmarshal(m, b) -} -func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic) -} -func (m *HelloRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_HelloRequest.Merge(m, src) -} -func (m *HelloRequest) XXX_Size() int { - return xxx_messageInfo_HelloRequest.Size(m) -} -func (m *HelloRequest) XXX_DiscardUnknown() { - xxx_messageInfo_HelloRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_HelloRequest proto.InternalMessageInfo - -func (m *HelloRequest) GetName() string { - if m != nil { - return m.Name +func (x *HelloRequest) Reset() { + *x = HelloRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_samples_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return "" -} - -// The response message containing the greetings -type User struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` - Age int32 `protobuf:"varint,3,opt,name=age,proto3" json:"age,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *User) Reset() { *m = User{} } -func (m *User) String() string { return proto.CompactTextString(m) } -func (*User) ProtoMessage() {} -func (*User) Descriptor() ([]byte, []int) { - return fileDescriptor_67d196fe99e714eb, []int{1} } -func (m *User) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_User.Unmarshal(m, b) -} -func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_User.Marshal(b, m, deterministic) -} -func (m *User) XXX_Merge(src proto.Message) { - xxx_messageInfo_User.Merge(m, src) -} -func (m *User) XXX_Size() int { - return xxx_messageInfo_User.Size(m) -} -func (m *User) XXX_DiscardUnknown() { - xxx_messageInfo_User.DiscardUnknown(m) +func (x *HelloRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_User proto.InternalMessageInfo +func (*HelloRequest) ProtoMessage() {} -func (m *User) GetName() string { - if m != nil { - return m.Name +func (x *HelloRequest) ProtoReflect() protoreflect.Message { + mi := &file_samples_api_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 "" + return mi.MessageOf(x) } -func (m *User) GetId() string { - if m != nil { - return m.Id - } - return "" +// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. +func (*HelloRequest) Descriptor() ([]byte, []int) { + return file_samples_api_proto_rawDescGZIP(), []int{0} } -func (m *User) GetAge() int32 { - if m != nil { - return m.Age +func (x *HelloRequest) GetName() string { + if x != nil { + return x.Name } - return 0 -} - -func init() { - proto.RegisterType((*HelloRequest)(nil), "api.HelloRequest") - proto.RegisterType((*User)(nil), "api.User") + return "" } -func init() { proto.RegisterFile("samples_api.proto", fileDescriptor_67d196fe99e714eb) } - -var fileDescriptor_67d196fe99e714eb = []byte{ - // 189 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x4e, 0xcc, 0x2d, - 0xc8, 0x49, 0x2d, 0x8e, 0x4f, 0x2c, 0xc8, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x4e, - 0x2c, 0xc8, 0x54, 0x52, 0xe2, 0xe2, 0xf1, 0x48, 0xcd, 0xc9, 0xc9, 0x0f, 0x4a, 0x2d, 0x2c, 0x4d, - 0x2d, 0x2e, 0x11, 0x12, 0xe2, 0x62, 0xc9, 0x4b, 0xcc, 0x4d, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, - 0x0c, 0x02, 0xb3, 0x95, 0x6c, 0xb8, 0x58, 0x42, 0x8b, 0x53, 0x8b, 0xb0, 0xc9, 0x09, 0xf1, 0x71, - 0x31, 0x65, 0xa6, 0x48, 0x30, 0x81, 0x45, 0x98, 0x32, 0x53, 0x84, 0x04, 0xb8, 0x98, 0x13, 0xd3, - 0x53, 0x25, 0x98, 0x15, 0x18, 0x35, 0x58, 0x83, 0x40, 0x4c, 0xa3, 0x6c, 0x2e, 0x76, 0xf7, 0xa2, - 0xd4, 0xd4, 0x92, 0xd4, 0x22, 0x21, 0x2d, 0x2e, 0x8e, 0xe0, 0xc4, 0x4a, 0xb0, 0x7d, 0x42, 0x82, - 0x7a, 0x20, 0x97, 0x20, 0xdb, 0x2d, 0xc5, 0x09, 0x16, 0x02, 0x59, 0xa5, 0xc4, 0x20, 0x64, 0xc2, - 0xc5, 0x07, 0x53, 0x1b, 0x5c, 0x52, 0x94, 0x9a, 0x98, 0x4b, 0x48, 0x87, 0x06, 0xa3, 0x01, 0xa3, - 0x13, 0x47, 0x14, 0x9b, 0x9e, 0xbe, 0x75, 0x62, 0x41, 0x66, 0x12, 0x1b, 0xd8, 0x93, 0xc6, 0x80, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x66, 0xf8, 0x73, 0xf9, 0x00, 0x00, 0x00, -} +// The response message containing the greetings +type User struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -type greeterDubbo3Client struct { - cc *dubbo3.TripleConn + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Age int32 `protobuf:"varint,3,opt,name=age,proto3" json:"age,omitempty"` } -func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient { - return &greeterDubbo3Client{cc} -} -func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*User, common.ErrorWithAttachment) { - out := new(User) - interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string) - return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) -} -func (c *greeterDubbo3Client) SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloStreamClient, error) { - interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string) - stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/SayHelloStream", opts...) - if err != nil { - return nil, err +func (x *User) Reset() { + *x = User{} + if protoimpl.UnsafeEnabled { + mi := &file_samples_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - x := &greeterSayHelloStreamClient{stream} - return x, nil } -// GreeterClientImpl is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*User, common.ErrorWithAttachment) - // Sends a greeting via stream - SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloStreamClient, error) +func (x *User) String() string { + return protoimpl.X.MessageStringOf(x) } -type GreeterClientImpl struct { - // Sends a greeting - SayHello func(ctx context.Context, in *HelloRequest) (*User, error) - // Sends a greeting via stream - SayHelloStream func(ctx context.Context) (Greeter_SayHelloStreamClient, error) -} - -type Greeter_SayHelloClient interface { - CloseAndRecv() (*User, error) - grpc.ClientStream -} - -type greeterSayHelloClient struct { - grpc.ClientStream -} +func (*User) ProtoMessage() {} -func (x *greeterSayHelloClient) CloseAndRecv() (*User, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err +func (x *User) ProtoReflect() protoreflect.Message { + mi := &file_samples_api_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - m := new(User) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -type Greeter_SayHelloStreamClient interface { - Send(*HelloRequest) error - Recv() (*User, error) - grpc.ClientStream -} - -type greeterSayHelloStreamClient struct { - grpc.ClientStream + return mi.MessageOf(x) } -func (x *greeterSayHelloStreamClient) Send(m *HelloRequest) error { - return x.ClientStream.SendMsg(m) +// Deprecated: Use User.ProtoReflect.Descriptor instead. +func (*User) Descriptor() ([]byte, []int) { + return file_samples_api_proto_rawDescGZIP(), []int{1} } -func (x *greeterSayHelloStreamClient) Recv() (*User, error) { - m := new(User) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +func (x *User) GetName() string { + if x != nil { + return x.Name } - return m, nil -} - -func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient { - return NewGreeterDubbo3Client(cc) -} - -// GreeterServer is the server API for Greeter service. -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*User, error) - // Sends a greeting via stream - SayHelloStream(Greeter_SayHelloStreamServer) error -} - -type GreeterProviderBase struct { - proxyImpl protocol.Invoker -} - -func (s *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - s.proxyImpl = impl -} - -func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker { - return s.proxyImpl + return "" } -func _Triple_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - base := srv.(dgrpc.Dubbo3GrpcService) - args := []interface{}{} - args = append(args, in) - invo := invocation.NewRPCInvocation("SayHello", args, nil) - if interceptor == nil { - result := base.GetProxyImpl().Invoke(ctx, invo) - return result, result.Error() - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/api.Greeter/SayHello", +func (x *User) GetId() string { + if x != nil { + return x.Id } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - result := base.GetProxyImpl().Invoke(context.Background(), invo) - return result.Result(), result.Error() - } - return interceptor(ctx, in, info, handler) + return "" } -func _Triple_Greeter_SayHelloStream_Handler(srv interface{}, stream grpc.ServerStream) error { - _, ok := srv.(dgrpc.Dubbo3GrpcService) - invo := invocation.NewRPCInvocation("SayHelloStream", nil, nil) - if !ok { - fmt.Println(invo) - return nil +func (x *User) GetAge() int32 { + if x != nil { + return x.Age } - return srv.(GreeterServer).SayHelloStream(&greeterSayHelloStreamServer{stream}) -} - -type Greeter_SayHelloStreamServer interface { - Send(*User) error - Recv() (*HelloRequest, error) - grpc.ServerStream -} - -type greeterSayHelloStreamServer struct { - grpc.ServerStream + return 0 } -func (x *greeterSayHelloStreamServer) Send(m *User) error { - return x.ServerStream.SendMsg(m) -} +var File_samples_api_proto protoreflect.FileDescriptor + +var file_samples_api_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x5f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x61, 0x70, 0x69, 0x22, 0x22, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3c, 0x0a, 0x04, + 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x32, 0x6b, 0x0a, 0x07, 0x47, 0x72, + 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x12, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, + 0x00, 0x12, 0x34, 0x0a, 0x0e, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x12, 0x11, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x09, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x2f, 0x3b, 0x61, 0x70, + 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_samples_api_proto_rawDescOnce sync.Once + file_samples_api_proto_rawDescData = file_samples_api_proto_rawDesc +) -func (x *greeterSayHelloStreamServer) Recv() (*HelloRequest, error) { - m := new(HelloRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err +func file_samples_api_proto_rawDescGZIP() []byte { + file_samples_api_proto_rawDescOnce.Do(func() { + file_samples_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_samples_api_proto_rawDescData) + }) + return file_samples_api_proto_rawDescData +} + +var file_samples_api_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_samples_api_proto_goTypes = []interface{}{ + (*HelloRequest)(nil), // 0: api.HelloRequest + (*User)(nil), // 1: api.User +} +var file_samples_api_proto_depIdxs = []int32{ + 0, // 0: api.Greeter.SayHello:input_type -> api.HelloRequest + 0, // 1: api.Greeter.SayHelloStream:input_type -> api.HelloRequest + 1, // 2: api.Greeter.SayHello:output_type -> api.User + 1, // 3: api.Greeter.SayHelloStream:output_type -> api.User + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] 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_samples_api_proto_init() } +func file_samples_api_proto_init() { + if File_samples_api_proto != nil { + return } - return m, nil -} - -func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc { - return &grpc.ServiceDesc{ - ServiceName: "api.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Triple_Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "SayHelloStream", - Handler: _Triple_Greeter_SayHelloStream_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "samples_api.proto", + if !protoimpl.UnsafeEnabled { + file_samples_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_samples_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*User); 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_samples_api_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_samples_api_proto_goTypes, + DependencyIndexes: file_samples_api_proto_depIdxs, + MessageInfos: file_samples_api_proto_msgTypes, + }.Build() + File_samples_api_proto = out.File + file_samples_api_proto_rawDesc = nil + file_samples_api_proto_goTypes = nil + file_samples_api_proto_depIdxs = nil } diff --git a/api/samples_api_triple.pb.go b/api/samples_api_triple.pb.go new file mode 100644 index 000000000..58b12bef8 --- /dev/null +++ b/api/samples_api_triple.pb.go @@ -0,0 +1,236 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Code generated by protoc-gen-go-triple. DO NOT EDIT. +// versions: +// - protoc-gen-go-triple v1.0.0 +// - protoc v3.14.0 +// source: samples_api.proto + +package api + +import ( + context "context" + fmt "fmt" +) + +import ( + protocol "dubbo.apache.org/dubbo-go/v3/protocol" + dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3" + invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation" + + common "github.com/dubbogo/triple/pkg/common" + constant "github.com/dubbogo/triple/pkg/common/constant" + triple "github.com/dubbogo/triple/pkg/triple" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion7 + +// GreeterClient is the client API for Greeter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type GreeterClient interface { + // Sends a greeting + SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*User, common.ErrorWithAttachment) + // Sends a greeting via stream + SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloStreamClient, error) +} + +type greeterClient struct { + cc *triple.TripleConn +} + +type GreeterClientImpl struct { + SayHello func(ctx context.Context, in *HelloRequest) (*User, error) + SayHelloStream func(ctx context.Context) (Greeter_SayHelloStreamClient, error) +} + +func (c *GreeterClientImpl) GetDubboStub(cc *triple.TripleConn) GreeterClient { + return NewGreeterClient(cc) +} + +func NewGreeterClient(cc *triple.TripleConn) GreeterClient { + return &greeterClient{cc} +} + +func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*User, common.ErrorWithAttachment) { + out := new(User) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) +} + +func (c *greeterClient) SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloStreamClient, error) { + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/SayHelloStream", opts...) + if err != nil { + return nil, err + } + x := &greeterSayHelloStreamClient{stream} + return x, nil +} + +type Greeter_SayHelloStreamClient interface { + Send(*HelloRequest) error + Recv() (*User, error) + grpc.ClientStream +} + +type greeterSayHelloStreamClient struct { + grpc.ClientStream +} + +func (x *greeterSayHelloStreamClient) Send(m *HelloRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *greeterSayHelloStreamClient) Recv() (*User, error) { + m := new(User) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// GreeterServer is the server API for Greeter service. +// All implementations must embed UnimplementedGreeterServer +// for forward compatibility +type GreeterServer interface { + // Sends a greeting + SayHello(context.Context, *HelloRequest) (*User, error) + // Sends a greeting via stream + SayHelloStream(Greeter_SayHelloStreamServer) error + mustEmbedUnimplementedGreeterServer() +} + +// UnimplementedGreeterServer must be embedded to have forward compatible implementations. +type UnimplementedGreeterServer struct { + proxyImpl protocol.Invoker +} + +func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*User, error) { + return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +} +func (UnimplementedGreeterServer) SayHelloStream(Greeter_SayHelloStreamServer) error { + return status.Errorf(codes.Unimplemented, "method SayHelloStream not implemented") +} +func (s *UnimplementedGreeterServer) XXX_SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *UnimplementedGreeterServer) XXX_GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +func (s *UnimplementedGreeterServer) XXX_ServiceDesc() *grpc.ServiceDesc { + return &Greeter_ServiceDesc +} +func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} + +// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GreeterServer will +// result in compilation errors. +type UnsafeGreeterServer interface { + mustEmbedUnimplementedGreeterServer() +} + +func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { + s.RegisterService(&Greeter_ServiceDesc, srv) +} + +func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HelloRequest) + if err := dec(in); err != nil { + return nil, err + } + base := srv.(dubbo3.Dubbo3GrpcService) + args := []interface{}{} + args = append(args, in) + invo := invocation.NewRPCInvocation("SayHello", args, nil) + if interceptor == nil { + result := base.XXX_GetProxyImpl().Invoke(ctx, invo) + return result, result.Error() + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/api.Greeter/SayHello", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Greeter_SayHelloStream_Handler(srv interface{}, stream grpc.ServerStream) error { + _, ok := srv.(dubbo3.Dubbo3GrpcService) + invo := invocation.NewRPCInvocation("SayHelloStream", nil, nil) + if !ok { + fmt.Println(invo) + return nil + } + return srv.(GreeterServer).SayHelloStream(&greeterSayHelloStreamServer{stream}) +} + +type Greeter_SayHelloStreamServer interface { + Send(*User) error + Recv() (*HelloRequest, error) + grpc.ServerStream +} + +type greeterSayHelloStreamServer struct { + grpc.ServerStream +} + +func (x *greeterSayHelloStreamServer) Send(m *User) error { + return x.ServerStream.SendMsg(m) +} + +func (x *greeterSayHelloStreamServer) Recv() (*HelloRequest, error) { + m := new(HelloRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Greeter_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.Greeter", + HandlerType: (*GreeterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SayHello", + Handler: _Greeter_SayHello_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "SayHelloStream", + Handler: _Greeter_SayHelloStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "samples_api.proto", +} diff --git a/config-api/configcenter/nacos/go-server/cmd/server.go b/config-api/configcenter/nacos/go-server/cmd/server.go index 659c31cfe..7a09a4558 100644 --- a/config-api/configcenter/nacos/go-server/cmd/server.go +++ b/config-api/configcenter/nacos/go-server/cmd/server.go @@ -52,7 +52,7 @@ dubbo: interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible with grpc or dubbo-java` type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/config-api/configcenter/zookeeper/go-server/cmd/server.go b/config-api/configcenter/zookeeper/go-server/cmd/server.go index 5572d63f6..d53f40a24 100644 --- a/config-api/configcenter/zookeeper/go-server/cmd/server.go +++ b/config-api/configcenter/zookeeper/go-server/cmd/server.go @@ -52,7 +52,7 @@ dubbo: interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible with grpc or dubbo-java` type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/config-api/rpc/triple/go-server/cmd/server.go b/config-api/rpc/triple/go-server/cmd/server.go index cbddde5fc..4b8e02503 100644 --- a/config-api/rpc/triple/go-server/cmd/server.go +++ b/config-api/rpc/triple/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/configcenter/apollo/go-server/cmd/server.go b/configcenter/apollo/go-server/cmd/server.go index ff49ef6de..fb212cbf8 100644 --- a/configcenter/apollo/go-server/cmd/server.go +++ b/configcenter/apollo/go-server/cmd/server.go @@ -41,7 +41,7 @@ var ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/configcenter/nacos/go-server/cmd/server.go b/configcenter/nacos/go-server/cmd/server.go index 8690ed9b0..1ad4db807 100644 --- a/configcenter/nacos/go-server/cmd/server.go +++ b/configcenter/nacos/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/configcenter/zookeeper/go-server/cmd/server.go b/configcenter/zookeeper/go-server/cmd/server.go index 8690ed9b0..1ad4db807 100644 --- a/configcenter/zookeeper/go-server/cmd/server.go +++ b/configcenter/zookeeper/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/context/triple/go-server/cmd/server.go b/context/triple/go-server/cmd/server.go index 3998b62ed..ee4a81150 100644 --- a/context/triple/go-server/cmd/server.go +++ b/context/triple/go-server/cmd/server.go @@ -34,7 +34,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/direct/go-server/cmd/server.go b/direct/go-server/cmd/server.go index 151424047..ba2271b05 100644 --- a/direct/go-server/cmd/server.go +++ b/direct/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/filter/custom/go-server/cmd/server.go b/filter/custom/go-server/cmd/server.go index 151424047..ba2271b05 100644 --- a/filter/custom/go-server/cmd/server.go +++ b/filter/custom/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/go.mod b/go.mod index b57125b03..669542b0c 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ module github.com/apache/dubbo-go-samples require ( - dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211027072544-4d4fb6ed2f6c + dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211029104429-bfc60c2496f9 github.com/apache/dubbo-go-hessian2 v1.9.4-0.20210917102639-74a8ece5f3cb github.com/dubbogo/gost v1.11.19 github.com/dubbogo/net v0.0.4 - github.com/dubbogo/triple v1.0.8 + github.com/dubbogo/triple v1.0.9-0.20211029101533-26805fcfcf62 github.com/golang/protobuf v1.5.2 github.com/opentracing/opentracing-go v1.2.0 github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5 diff --git a/go.sum b/go.sum index 7d50cd5c8..fbdefbdcf 100644 --- a/go.sum +++ b/go.sum @@ -35,8 +35,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 contrib.go.opencensus.io/exporter/prometheus v0.4.0 h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs= contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0QmaQNhGnptITnPQB+z1+qeFB0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211027072544-4d4fb6ed2f6c h1:GyKAO86EcK7+1i9oPE1/SyfgvjCdeEP0YsydlPi/wBc= -dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211027072544-4d4fb6ed2f6c/go.mod h1:caCkQ4jw6tphBSP+NEd2/EZGOXK71VoD9yyw8qPpYxo= +dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211029104429-bfc60c2496f9 h1:htha09ArXMUo7yo/Qgg8POcfRV7g9InaQHWfq7x47RY= +dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2.0.20211029104429-bfc60c2496f9/go.mod h1:oXQ3d7O7JrossmlB0IwAazOTPltuaVPyb0p1tCIcIPU= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= @@ -199,8 +199,8 @@ github.com/dubbogo/gost v1.11.19/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZT github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8= github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc= -github.com/dubbogo/triple v1.0.8 h1:M3p2t+Bx6z1RbVMm4GjrZKFpe8Ar0g6J0m/6fYU46tQ= -github.com/dubbogo/triple v1.0.8/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw= +github.com/dubbogo/triple v1.0.9-0.20211029101533-26805fcfcf62 h1:f06hq7IXtY6ViNznSuYCG1waws+1C3KOezPP+4C3+Jo= +github.com/dubbogo/triple v1.0.9-0.20211029101533-26805fcfcf62/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= diff --git a/helloworld/go-server/cmd/server.go b/helloworld/go-server/cmd/server.go index 151424047..ba2271b05 100644 --- a/helloworld/go-server/cmd/server.go +++ b/helloworld/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/logger/custom/cmd/main.go b/logger/custom/cmd/main.go index 2bec51177..73df7788b 100644 --- a/logger/custom/cmd/main.go +++ b/logger/custom/cmd/main.go @@ -35,7 +35,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } type customLogger struct { diff --git a/logger/default/cmd/main.go b/logger/default/cmd/main.go index d9f0f8e58..e4b34f73e 100644 --- a/logger/default/cmd/main.go +++ b/logger/default/cmd/main.go @@ -33,7 +33,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func main() { diff --git a/logger/level/cmd/main.go b/logger/level/cmd/main.go index f347e30a0..495b5561e 100644 --- a/logger/level/cmd/main.go +++ b/logger/level/cmd/main.go @@ -33,7 +33,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func main() { diff --git a/logger/rolling/cmd/main.go b/logger/rolling/cmd/main.go index 21cb843fe..520dc58d0 100644 --- a/logger/rolling/cmd/main.go +++ b/logger/rolling/cmd/main.go @@ -33,7 +33,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func main() { diff --git a/metrics/go-server/cmd/server.go b/metrics/go-server/cmd/server.go index c278dc0c3..87536e4d0 100644 --- a/metrics/go-server/cmd/server.go +++ b/metrics/go-server/cmd/server.go @@ -35,7 +35,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/registry/servicediscovery/nacos/go-server/cmd/server.go b/registry/servicediscovery/nacos/go-server/cmd/server.go index ddbb4eccf..5e2b51f3e 100644 --- a/registry/servicediscovery/nacos/go-server/cmd/server.go +++ b/registry/servicediscovery/nacos/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/registry/servicediscovery/zookeeper/go-server/cmd/server.go b/registry/servicediscovery/zookeeper/go-server/cmd/server.go index ddbb4eccf..5e2b51f3e 100644 --- a/registry/servicediscovery/zookeeper/go-server/cmd/server.go +++ b/registry/servicediscovery/zookeeper/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/registry/zookeeper/go-server/cmd/server.go b/registry/zookeeper/go-server/cmd/server.go index a6a1bc364..5783e67be 100644 --- a/registry/zookeeper/go-server/cmd/server.go +++ b/registry/zookeeper/go-server/cmd/server.go @@ -41,7 +41,7 @@ var ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/route/meshroute/go-server/cmd/server.go b/route/meshroute/go-server/cmd/server.go index 76e3e511a..ba2e7ca8b 100644 --- a/route/meshroute/go-server/cmd/server.go +++ b/route/meshroute/go-server/cmd/server.go @@ -32,7 +32,7 @@ import ( ) type GreeterProvider struct { - api.GreeterProviderBase + api.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*api.User, error) { diff --git a/rpc/triple/msgpack/go-server/cmd/server.go b/rpc/triple/msgpack/go-server/cmd/server.go index 51d91206d..ef64ef940 100644 --- a/rpc/triple/msgpack/go-server/cmd/server.go +++ b/rpc/triple/msgpack/go-server/cmd/server.go @@ -30,8 +30,6 @@ import ( "dubbo.apache.org/dubbo-go/v3/common/logger" "dubbo.apache.org/dubbo-go/v3/config" _ "dubbo.apache.org/dubbo-go/v3/imports" - - gxlog "github.com/dubbogo/gost/log" ) import ( @@ -42,14 +40,14 @@ type UserProvider struct { } func (u UserProvider) GetUser(ctx context.Context, user *api.User) (*api.User, error) { - gxlog.CInfo("req:%#v", user) - rsp := api.User{ + logger.Infof("req:%#v", user) + rsp := &api.User{ Id: "12345", Name: "Hello " + user.Name, Age: 18, } - gxlog.CInfo("rsp:%#v", rsp) - return &rsp, nil + logger.Infof("rsp:%+v", rsp) + return rsp, nil } var ( diff --git a/rpc/triple/pb/dubbogo-grpc/go-server/pkg/greeter.go b/rpc/triple/pb/dubbogo-grpc/go-server/pkg/greeter.go index 8d298e6ef..5cbac7212 100644 --- a/rpc/triple/pb/dubbogo-grpc/go-server/pkg/greeter.go +++ b/rpc/triple/pb/dubbogo-grpc/go-server/pkg/greeter.go @@ -33,7 +33,7 @@ import ( ) type GreeterProvider struct { - triplepb.GreeterProviderBase + triplepb.UnimplementedGreeterServer } func (s *GreeterProvider) SayHelloStream(svr triplepb.Greeter_SayHelloStreamServer) error { diff --git a/rpc/triple/pb/dubbogo-java/go-server/pkg/greeter.go b/rpc/triple/pb/dubbogo-java/go-server/pkg/greeter.go index bc1988149..5edc79e1c 100644 --- a/rpc/triple/pb/dubbogo-java/go-server/pkg/greeter.go +++ b/rpc/triple/pb/dubbogo-java/go-server/pkg/greeter.go @@ -30,7 +30,7 @@ import ( ) type GreeterProvider struct { - pb.GreeterProviderBase + pb.UnimplementedGreeterServer } func (s *GreeterProvider) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.User, error) {