This is an automated email from the ASF dual-hosted git repository. laurence pushed a commit to branch ftr/metrics in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
commit bfc60c2496f9d46296b8537719dd0e20e5f23092 Author: LaurenceLiZhixin <[email protected]> AuthorDate: Fri Oct 29 18:44:29 2021 +0800 fix: update protoc-gen-go-triple --- cluster/router/chain/chain.go | 2 +- common/logger/logger.go | 2 +- config/config_center_config.go | 2 +- config/config_center_config_test.go | 2 + config/dubbogo.yaml.json | 1 + config/logger_config.go | 2 +- go.mod | 2 +- go.sum | 4 +- metrics/prometheus/reporter.go | 2 +- protocol/dubbo3/common_test.go | 43 +-- protocol/dubbo3/dubbo3_protocol.go | 10 +- protocol/dubbo3/dubbo3_protocol_test.go | 2 +- protocol/dubbo3/internal/helloworld.pb.go | 363 +++++++++++------------ protocol/dubbo3/internal/helloworld.proto | 1 + protocol/dubbo3/internal/helloworld_triple.pb.go | 168 +++++++++++ protocol/dubbo3/internal/server.go | 2 +- 16 files changed, 358 insertions(+), 250 deletions(-) diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index e366a2a..7130947 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -114,7 +114,7 @@ func NewRouterChain() (*RouterChain, error) { for key, routerFactory := range routerFactories { r, err := routerFactory().NewPriorityRouter() if r == nil || err != nil { - logger.Errorf("router chain build router fail! routerFactories key:%s error:%v", key, err) + logger.Warnf("router chain build router fail! routerFactories key:%s reason is :%v", key, err) continue } routers = append(routers, r) diff --git a/common/logger/logger.go b/common/logger/logger.go index bc19e46..66ecf4a 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -79,7 +79,7 @@ func InitLogger(conf *Config) { EncodeCaller: zapcore.ShortCallerEncoder, } config.ZapConfig = &zap.Config{ - Level: zap.NewAtomicLevelAt(zap.DebugLevel), + Level: zap.NewAtomicLevelAt(zap.InfoLevel), Development: false, Encoding: "console", EncoderConfig: zapLoggerEncoderConfig, diff --git a/config/config_center_config.go b/config/config_center_config.go index 956a39d..708f198 100644 --- a/config/config_center_config.go +++ b/config/config_center_config.go @@ -166,7 +166,7 @@ func (c *CenterConfig) GetDynamicConfiguration() (config_center.DynamicConfigura } dynamicConfig, err := c.CreateDynamicConfiguration() if err != nil { - logger.Errorf("Create dynamic configuration error , error message is %v", err) + logger.Warnf("Create dynamic configuration error , error message is %v", err) return nil, errors.WithStack(err) } c.DynamicConfiguration = dynamicConfig diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go index dca8632..e77e593 100644 --- a/config/config_center_config_test.go +++ b/config/config_center_config_test.go @@ -20,9 +20,11 @@ package config import ( "testing" ) + import ( "github.com/stretchr/testify/assert" ) + import ( _ "dubbo.apache.org/dubbo-go/v3/config_center/apollo" ) diff --git a/config/dubbogo.yaml.json b/config/dubbogo.yaml.json new file mode 100644 index 0000000..d4a15c5 --- /dev/null +++ b/config/dubbogo.yaml.json @@ -0,0 +1 @@ +{"appId":"dubbo-go","cluster":"default","namespaceName":"dubbogo.yaml","releaseKey":"20211024004732-b3c4b7517738ccda","configurations":{"content":"dubbo:\r\n registries:\r\n nacos:\r\n timeout: 20s\r\n group: dev\r\n address: nacos://127.0.0.1:8848"}} diff --git a/config/logger_config.go b/config/logger_config.go index 444bc38..d36b6d7 100644 --- a/config/logger_config.go +++ b/config/logger_config.go @@ -37,7 +37,7 @@ import ( ) type ZapConfig struct { - Level string `default:"debug" json:"level,omitempty" yaml:"level" property:"level"` + Level string `default:"info" json:"level,omitempty" yaml:"level" property:"level"` Development bool `default:"false" json:"development,omitempty" yaml:"development" property:"development"` DisableCaller bool `default:"false" json:"disable-caller,omitempty" yaml:"disable-caller" property:"disable-caller"` DisableStacktrace bool `default:"false" json:"disable-stacktrace,omitempty" yaml:"disable-stacktrace" property:"disable-stacktrace"` diff --git a/go.mod b/go.mod index 1333f17..b148bf1 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/creasty/defaults v1.5.2 github.com/dubbogo/go-zookeeper v1.0.3 github.com/dubbogo/gost v1.11.19 - github.com/dubbogo/triple v1.0.8 + github.com/dubbogo/triple v1.0.9-0.20211029101533-26805fcfcf62 github.com/emicklei/go-restful/v3 v3.7.1 github.com/fsnotify/fsnotify v1.5.1 github.com/ghodss/yaml v1.0.0 diff --git a/go.sum b/go.sum index e995df9..1d1d47a 100644 --- a/go.sum +++ b/go.sum @@ -195,8 +195,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/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 55d1bd6..15771a4 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -236,7 +236,7 @@ func newPrometheusReporter(reporterConfig *metrics.ReporterConfig) metrics.Repor mux := http.NewServeMux() mux.Handle(reporterConfig.Path, metricsExporter) if err := http.ListenAndServe(":"+reporterConfig.Port, mux); err != nil { - logger.Errorf("new prometheus reporter with error = %s", err) + logger.Warnf("new prometheus reporter with error = %s", err) } }() }) diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go index f137e84..5daac36 100644 --- a/protocol/dubbo3/common_test.go +++ b/protocol/dubbo3/common_test.go @@ -28,7 +28,6 @@ import ( import ( "dubbo.apache.org/dubbo-go/v3/config" - "dubbo.apache.org/dubbo-go/v3/protocol" "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal" "dubbo.apache.org/dubbo-go/v3/protocol/invocation" ) @@ -39,13 +38,11 @@ func addService() { } type greeterProvider struct { - *greeterProviderBase + internal.UnimplementedGreeterServer } func newGreeterProvider() *greeterProvider { - return &greeterProvider{ - greeterProviderBase: &greeterProviderBase{}, - } + return &greeterProvider{} } func (g *greeterProvider) SayHello(ctx context.Context, req *internal.HelloRequest) (reply *internal.HelloReply, err error) { @@ -53,38 +50,6 @@ func (g *greeterProvider) SayHello(ctx context.Context, req *internal.HelloReque return &internal.HelloReply{Message: "this is message from reply"}, nil } -func (g *greeterProvider) Reference() string { - return "DubboGreeterImpl" -} - -// code generated by greeter.go -type greeterProviderBase struct { - proxyImpl protocol.Invoker -} - -func (g *greeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - g.proxyImpl = impl -} - -func (g *greeterProviderBase) GetProxyImpl() protocol.Invoker { - return g.proxyImpl -} - -func (g *greeterProviderBase) ServiceDesc() *native_grpc.ServiceDesc { - return &native_grpc.ServiceDesc{ - ServiceName: "helloworld.Greeter", - HandlerType: (*internal.GreeterServer)(nil), - Methods: []native_grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: dubboGreeterSayHelloHandler, - }, - }, - Streams: []native_grpc.StreamDesc{}, - Metadata: "helloworld.proto", - } -} - func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor native_grpc.UnaryServerInterceptor) (interface{}, error) { @@ -99,7 +64,7 @@ func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context, invo := invocation.NewRPCInvocation("SayHello", args, nil) if interceptor == nil { - result := base.GetProxyImpl().Invoke(context.Background(), invo) + result := base.XXX_GetProxyImpl().Invoke(context.Background(), invo) return result.Result(), result.Error() } info := &native_grpc.UnaryServerInfo{ @@ -107,7 +72,7 @@ func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context, FullMethod: "/helloworld.Greeter/SayHello", } handler := func(context.Context, interface{}) (interface{}, error) { - result := base.GetProxyImpl().Invoke(context.Background(), invo) + result := base.XXX_GetProxyImpl().Invoke(context.Background(), invo) return result.Result(), result.Error() } return interceptor(ctx, in, info, handler) diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index e53b6a4..d0854df 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -87,9 +87,9 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { var triSerializationType tripleConstant.CodecType if serializationType == constant.PROTOBUF_SERIALIZATION { - m, ok := reflect.TypeOf(service).MethodByName("SetProxyImpl") + m, ok := reflect.TypeOf(service).MethodByName("XXX_SetProxyImpl") if !ok { - panic("method SetProxyImpl is necessary for triple service") + panic("method XXX_SetProxyImpl is necessary for triple service") } if invoker == nil { panic(fmt.Sprintf("no invoker found for servicekey: %v", url.ServiceKey())) @@ -160,11 +160,11 @@ func (dp *DubboProtocol) Destroy() { // Dubbo3GrpcService is gRPC service type Dubbo3GrpcService interface { // SetProxyImpl sets proxy. - SetProxyImpl(impl protocol.Invoker) + XXX_SetProxyImpl(impl protocol.Invoker) // GetProxyImpl gets proxy. - GetProxyImpl() protocol.Invoker + XXX_GetProxyImpl() protocol.Invoker // ServiceDesc gets an RPC service's specification. - ServiceDesc() *grpc.ServiceDesc + XXX_ServiceDesc() *grpc.ServiceDesc } type UnaryService struct { diff --git a/protocol/dubbo3/dubbo3_protocol_test.go b/protocol/dubbo3/dubbo3_protocol_test.go index 95e485d..b0baa35 100644 --- a/protocol/dubbo3/dubbo3_protocol_test.go +++ b/protocol/dubbo3/dubbo3_protocol_test.go @@ -36,7 +36,7 @@ import ( ) const ( - mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterImpl" + + mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterProvider" + "&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=org.apache.dubbo.DubboGreeterImpl" + "&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=" + "&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=" + diff --git a/protocol/dubbo3/internal/helloworld.pb.go b/protocol/dubbo3/internal/helloworld.pb.go index e265b30..f846788 100644 --- a/protocol/dubbo3/internal/helloworld.pb.go +++ b/protocol/dubbo3/internal/helloworld.pb.go @@ -16,257 +16,228 @@ */ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.14.0 // source: helloworld.proto package internal import ( - context "context" - fmt "fmt" - math "math" + reflect "reflect" + sync "sync" ) import ( - "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" -import ( - "dubbo.apache.org/dubbo-go/v3/protocol" - dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/grpc" - "dubbo.apache.org/dubbo-go/v3/protocol/invocation" + 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_17b8c58d586b62f2, []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_helloworld_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return "" } -// The response message containing the greetings -type HelloReply struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +func (x *HelloRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *HelloReply) Reset() { *m = HelloReply{} } -func (m *HelloReply) String() string { return proto.CompactTextString(m) } -func (*HelloReply) ProtoMessage() {} -func (*HelloReply) Descriptor() ([]byte, []int) { - return fileDescriptor_17b8c58d586b62f2, []int{1} -} +func (*HelloRequest) ProtoMessage() {} -func (m *HelloReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HelloReply.Unmarshal(m, b) -} -func (m *HelloReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HelloReply.Marshal(b, m, deterministic) -} -func (m *HelloReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_HelloReply.Merge(m, src) -} -func (m *HelloReply) XXX_Size() int { - return xxx_messageInfo_HelloReply.Size(m) -} -func (m *HelloReply) XXX_DiscardUnknown() { - xxx_messageInfo_HelloReply.DiscardUnknown(m) -} - -var xxx_messageInfo_HelloReply proto.InternalMessageInfo - -func (m *HelloReply) GetMessage() string { - if m != nil { - return m.Message +func (x *HelloRequest) ProtoReflect() protoreflect.Message { + mi := &file_helloworld_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 init() { - proto.RegisterType((*HelloRequest)(nil), "internal.HelloRequest") - proto.RegisterType((*HelloReply)(nil), "internal.HelloReply") -} - -func init() { proto.RegisterFile("helloworld.proto", fileDescriptor_17b8c58d586b62f2) } - -var fileDescriptor_17b8c58d586b62f2 = []byte{ - // 189 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x48, 0xcd, 0xc9, - 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc8, 0xcc, - 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0x51, 0x52, 0xe2, 0xe2, 0xf1, 0x00, 0xc9, 0x06, 0xa5, 0x16, - 0x96, 0xa6, 0x16, 0x97, 0x08, 0x09, 0x71, 0xb1, 0xe4, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30, - 0x6a, 0x70, 0x06, 0x81, 0xd9, 0x4a, 0x6a, 0x5c, 0x5c, 0x50, 0x35, 0x05, 0x39, 0x95, 0x42, 0x12, - 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0x30, 0x45, 0x30, 0xae, 0x91, 0x2b, 0x17, 0xbb, - 0x7b, 0x51, 0x6a, 0x6a, 0x49, 0x6a, 0x91, 0x90, 0x15, 0x17, 0x47, 0x70, 0x62, 0x25, 0x58, 0x97, - 0x90, 0x98, 0x1e, 0xcc, 0x36, 0x3d, 0x64, 0xab, 0xa4, 0x44, 0x30, 0xc4, 0x0b, 0x72, 0x2a, 0x95, - 0x18, 0x9c, 0xcc, 0xb8, 0xa4, 0x33, 0xf3, 0xf5, 0xd2, 0x8b, 0x0a, 0x92, 0xf5, 0x52, 0x2b, 0x12, - 0x73, 0x0b, 0x72, 0x52, 0x8b, 0xf5, 0x10, 0x3e, 0x70, 0xe2, 0x07, 0x2b, 0x0e, 0x07, 0xb1, 0x03, - 0x40, 0x9e, 0x09, 0x60, 0x5c, 0xc4, 0xc4, 0xec, 0xe1, 0x13, 0x9e, 0xc4, 0x06, 0xf6, 0x9b, 0x31, - 0x20, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x20, 0xe8, 0xd3, 0xef, 0x00, 0x00, 0x00, +// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. +func (*HelloRequest) Descriptor() ([]byte, []int) { + return file_helloworld_proto_rawDescGZIP(), []int{0} } -type greeterDubbo3Client struct { - cc *dubbo3.TripleConn +func (x *HelloRequest) GetName() string { + if x != nil { + return x.Name + } + return "" } -func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient { - return &greeterDubbo3Client{cc} -} -func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment) { - out := new(HelloReply) - interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string) - return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) -} +// The response message containing the greetings +type HelloReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -// 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) (*HelloReply, common.ErrorWithAttachment) + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` } -type GreeterClientImpl struct { - // Sends a greeting - SayHello func(ctx context.Context, in *HelloRequest) (*HelloReply, error) +func (x *HelloReply) Reset() { + *x = HelloReply{} + if protoimpl.UnsafeEnabled { + mi := &file_helloworld_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -type Greeter_SayHelloClient interface { - CloseAndRecv() (*HelloReply, error) - grpc.ClientStream +func (x *HelloReply) String() string { + return protoimpl.X.MessageStringOf(x) } -type greeterSayHelloClient struct { - grpc.ClientStream -} +func (*HelloReply) ProtoMessage() {} -func (x *greeterSayHelloClient) CloseAndRecv() (*HelloReply, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(HelloReply) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +func (x *HelloReply) ProtoReflect() protoreflect.Message { + mi := &file_helloworld_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 m, nil + return mi.MessageOf(x) } -func (c *GreeterClientImpl) Reference() string { - return "greeterImpl" +// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. +func (*HelloReply) Descriptor() ([]byte, []int) { + return file_helloworld_proto_rawDescGZIP(), []int{1} } -func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient { - return NewGreeterDubbo3Client(cc) +func (x *HelloReply) GetMessage() string { + if x != nil { + return x.Message + } + return "" } -// GreeterServer is the server API for Greeter service. -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) -} +var File_helloworld_proto protoreflect.FileDescriptor + +var file_helloworld_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 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, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, + 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, + 0x16, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, + 0x43, 0x0a, 0x1b, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x73, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x42, 0x0f, + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, + 0x01, 0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0xa2, 0x02, + 0x03, 0x48, 0x4c, 0x57, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_helloworld_proto_rawDescOnce sync.Once + file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc +) -type GreeterProviderBase struct { - proxyImpl protocol.Invoker +func file_helloworld_proto_rawDescGZIP() []byte { + file_helloworld_proto_rawDescOnce.Do(func() { + file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) + }) + return file_helloworld_proto_rawDescData } -func (s *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) { - s.proxyImpl = impl +var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_helloworld_proto_goTypes = []interface{}{ + (*HelloRequest)(nil), // 0: internal.HelloRequest + (*HelloReply)(nil), // 1: internal.HelloReply } - -func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker { - return s.proxyImpl +var file_helloworld_proto_depIdxs = []int32{ + 0, // 0: internal.Greeter.SayHello:input_type -> internal.HelloRequest + 1, // 1: internal.Greeter.SayHello:output_type -> internal.HelloReply + 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 (c *GreeterProviderBase) Reference() string { - return "greeterImpl" -} - -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.DubboGrpcService) - 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: "/internal.Greeter/SayHello", +func init() { file_helloworld_proto_init() } +func file_helloworld_proto_init() { + if File_helloworld_proto != nil { + return } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - result := base.GetProxyImpl().Invoke(context.Background(), invo) - return result.Result(), result.Error() + if !protoimpl.UnsafeEnabled { + file_helloworld_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_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - return interceptor(ctx, in, info, handler) -} - -func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc { - return &grpc.ServiceDesc{ - ServiceName: "internal.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Triple_Greeter_SayHello_Handler, - }, + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_helloworld_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", - } + GoTypes: file_helloworld_proto_goTypes, + DependencyIndexes: file_helloworld_proto_depIdxs, + MessageInfos: file_helloworld_proto_msgTypes, + }.Build() + File_helloworld_proto = out.File + file_helloworld_proto_rawDesc = nil + file_helloworld_proto_goTypes = nil + file_helloworld_proto_depIdxs = nil } diff --git a/protocol/dubbo3/internal/helloworld.proto b/protocol/dubbo3/internal/helloworld.proto index 7b62e20..ceb877a 100644 --- a/protocol/dubbo3/internal/helloworld.proto +++ b/protocol/dubbo3/internal/helloworld.proto @@ -21,6 +21,7 @@ option java_multiple_files = true; option java_package = "io.grpc.examples.helloworld"; option java_outer_classname = "HelloWorldProto"; option objc_class_prefix = "HLW"; +option go_package = "./;internal"; package internal; diff --git a/protocol/dubbo3/internal/helloworld_triple.pb.go b/protocol/dubbo3/internal/helloworld_triple.pb.go new file mode 100644 index 0000000..b9c2f7f --- /dev/null +++ b/protocol/dubbo3/internal/helloworld_triple.pb.go @@ -0,0 +1,168 @@ +/* + * 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: helloworld.proto + +package internal + +import ( + context "context" +) + +import ( + 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" +) + +import ( + protocol "dubbo.apache.org/dubbo-go/v3/protocol" + invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation" +) + +// 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) (*HelloReply, common.ErrorWithAttachment) +} + +type greeterClient struct { + cc *triple.TripleConn +} + +type GreeterClientImpl struct { + SayHello func(ctx context.Context, in *HelloRequest) (*HelloReply, 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) (*HelloReply, common.ErrorWithAttachment) { + out := new(HelloReply) + interfaceKey := ctx.Value(constant.InterfaceKey).(string) + return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out) +} + +// 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) (*HelloReply, error) + mustEmbedUnimplementedGreeterServer() +} + +// UnimplementedGreeterServer must be embedded to have forward compatible implementations. +type UnimplementedGreeterServer struct { + proxyImpl protocol.Invoker +} + +func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +} +func (s *UnimplementedGreeterServer) XXX_SetProxyImpl(impl protocol.Invoker) { + s.proxyImpl = impl +} + +func (s *UnimplementedGreeterServer) XXX_GetProxyImpl() protocol.Invoker { + return s.proxyImpl +} + +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) +} + +// Dubbo3GrpcService is gRPC service +type Dubbo3GrpcService interface { + // SetProxyImpl sets proxy. + XXX_SetProxyImpl(impl protocol.Invoker) + // GetProxyImpl gets proxy. + XXX_GetProxyImpl() protocol.Invoker + // ServiceDesc gets an RPC service's specification. + XXX_ServiceDesc() *grpc.ServiceDesc +} + +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.(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: "/internal.Greeter/SayHello", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// 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: "internal.Greeter", + HandlerType: (*GreeterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SayHello", + Handler: _Greeter_SayHello_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "helloworld.proto", +} + +func (s *UnimplementedGreeterServer) XXX_ServiceDesc() *grpc.ServiceDesc { + return &Greeter_ServiceDesc +} diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go index 97245df..51021c8 100644 --- a/protocol/dubbo3/internal/server.go +++ b/protocol/dubbo3/internal/server.go @@ -32,7 +32,7 @@ import ( // server is used to implement helloworld.GreeterServer. type Server struct { - GreeterProviderBase + UnimplementedGreeterServer } // SayHello implements helloworld.GreeterServer
