FoghostCn commented on code in PR #2983:
URL: https://github.com/apache/dubbo-go/pull/2983#discussion_r2297373283
##########
metadata/metadata_service.go:
##########
@@ -218,27 +262,43 @@ func (e *serviceExporter) exportTripleV1(port string) {
invoker := proxyFactory.GetInvoker(ivkURL)
e.protocolExporter =
extension.GetProtocol(protocolwrapper.FILTER).Export(invoker)
e.service.(*DefaultMetadataService).setMetadataServiceURL(invoker.GetURL())
+ return nil
}
-func (e *serviceExporter) exportV2(port string) {
+// exportV2 exports MetadataServiceV2 using tri protocol with protobuf
serialization
+// Uses same port but different interface name for proper client discovery
+func (e *serviceExporter) exportV2(port string) error {
v2 := &MetadataServiceV2{delegate: e.service}
- // v2 only supports triple protocol
ivkURL := common.NewURLWithOptions(
common.WithPath(constant.MetadataServiceV2Name),
common.WithProtocol(constant.TriProtocol),
common.WithPort(port),
common.WithParamsValue(constant.GroupKey, e.opts.appName),
- common.WithParamsValue(constant.VersionKey, "2.0.0"),
+ common.WithParamsValue(constant.VersionKey,
constant.MetadataServiceV2Version),
common.WithInterface(constant.MetadataServiceV2Name),
common.WithMethods(strings.Split("getMetadataInfo,GetMetadataInfo", ",")),
+ // Note: No hessian2 serialization - V2 uses pure protobuf for
better performance
+ common.WithParamsValue(constant.ReleaseKey, constant.Version),
+ common.WithParamsValue(constant.MetadataTypeKey,
e.opts.metadataType),
+ common.WithParamsValue(constant.SideKey, constant.SideProvider),
common.WithAttribute(constant.ServiceInfoKey,
&MetadataServiceV2_ServiceInfo),
common.WithAttribute(constant.RpcServiceKey, v2),
)
+
+ // Register V2 service for client discovery
+ methods, err := common.ServiceMap.Register(ivkURL.Interface(),
ivkURL.Protocol, ivkURL.Group(), ivkURL.Version(), v2)
+ if err != nil {
+ return perrors.Errorf("failed to register MetadataServiceV2 %v:
%v", ivkURL.Interface(), err)
+ }
+ ivkURL.Methods = strings.Split(methods, ",")
+
proxyFactory := extension.GetProxyFactory("")
invoker := proxyFactory.GetInvoker(ivkURL)
e.v2Exporter =
extension.GetProtocol(protocolwrapper.FILTER).Export(invoker)
- // do not set, because it will override MetadataService
- //exporter.metadataService.SetMetadataServiceURL(ivkURL)
+
+ // Both V1 and V2 are now discoverable on same port with different
interface names
Review Comment:
e.opts.protocol == 'tri or 'dubbo' not both
##########
metadata/metadata_service.go:
##########
@@ -218,27 +262,43 @@ func (e *serviceExporter) exportTripleV1(port string) {
invoker := proxyFactory.GetInvoker(ivkURL)
e.protocolExporter =
extension.GetProtocol(protocolwrapper.FILTER).Export(invoker)
e.service.(*DefaultMetadataService).setMetadataServiceURL(invoker.GetURL())
+ return nil
}
-func (e *serviceExporter) exportV2(port string) {
+// exportV2 exports MetadataServiceV2 using tri protocol with protobuf
serialization
+// Uses same port but different interface name for proper client discovery
+func (e *serviceExporter) exportV2(port string) error {
v2 := &MetadataServiceV2{delegate: e.service}
- // v2 only supports triple protocol
ivkURL := common.NewURLWithOptions(
common.WithPath(constant.MetadataServiceV2Name),
common.WithProtocol(constant.TriProtocol),
common.WithPort(port),
common.WithParamsValue(constant.GroupKey, e.opts.appName),
- common.WithParamsValue(constant.VersionKey, "2.0.0"),
+ common.WithParamsValue(constant.VersionKey,
constant.MetadataServiceV2Version),
common.WithInterface(constant.MetadataServiceV2Name),
common.WithMethods(strings.Split("getMetadataInfo,GetMetadataInfo", ",")),
+ // Note: No hessian2 serialization - V2 uses pure protobuf for
better performance
+ common.WithParamsValue(constant.ReleaseKey, constant.Version),
+ common.WithParamsValue(constant.MetadataTypeKey,
e.opts.metadataType),
+ common.WithParamsValue(constant.SideKey, constant.SideProvider),
common.WithAttribute(constant.ServiceInfoKey,
&MetadataServiceV2_ServiceInfo),
common.WithAttribute(constant.RpcServiceKey, v2),
)
+
+ // Register V2 service for client discovery
+ methods, err := common.ServiceMap.Register(ivkURL.Interface(),
ivkURL.Protocol, ivkURL.Group(), ivkURL.Version(), v2)
+ if err != nil {
+ return perrors.Errorf("failed to register MetadataServiceV2 %v:
%v", ivkURL.Interface(), err)
+ }
+ ivkURL.Methods = strings.Split(methods, ",")
Review Comment:
What is the significance of this?
##########
metadata/metadata_service.go:
##########
@@ -218,27 +262,43 @@ func (e *serviceExporter) exportTripleV1(port string) {
invoker := proxyFactory.GetInvoker(ivkURL)
e.protocolExporter =
extension.GetProtocol(protocolwrapper.FILTER).Export(invoker)
e.service.(*DefaultMetadataService).setMetadataServiceURL(invoker.GetURL())
+ return nil
}
-func (e *serviceExporter) exportV2(port string) {
+// exportV2 exports MetadataServiceV2 using tri protocol with protobuf
serialization
+// Uses same port but different interface name for proper client discovery
+func (e *serviceExporter) exportV2(port string) error {
v2 := &MetadataServiceV2{delegate: e.service}
- // v2 only supports triple protocol
ivkURL := common.NewURLWithOptions(
common.WithPath(constant.MetadataServiceV2Name),
common.WithProtocol(constant.TriProtocol),
common.WithPort(port),
common.WithParamsValue(constant.GroupKey, e.opts.appName),
- common.WithParamsValue(constant.VersionKey, "2.0.0"),
+ common.WithParamsValue(constant.VersionKey,
constant.MetadataServiceV2Version),
common.WithInterface(constant.MetadataServiceV2Name),
common.WithMethods(strings.Split("getMetadataInfo,GetMetadataInfo", ",")),
+ // Note: No hessian2 serialization - V2 uses pure protobuf for
better performance
+ common.WithParamsValue(constant.ReleaseKey, constant.Version),
+ common.WithParamsValue(constant.MetadataTypeKey,
e.opts.metadataType),
+ common.WithParamsValue(constant.SideKey, constant.SideProvider),
common.WithAttribute(constant.ServiceInfoKey,
&MetadataServiceV2_ServiceInfo),
common.WithAttribute(constant.RpcServiceKey, v2),
)
+
+ // Register V2 service for client discovery
+ methods, err := common.ServiceMap.Register(ivkURL.Interface(),
ivkURL.Protocol, ivkURL.Group(), ivkURL.Version(), v2)
+ if err != nil {
+ return perrors.Errorf("failed to register MetadataServiceV2 %v:
%v", ivkURL.Interface(), err)
+ }
+ ivkURL.Methods = strings.Split(methods, ",")
Review Comment:
metadata service don't use service discovery
##########
metadata/metadata_service.go:
##########
@@ -298,11 +358,14 @@ func (mtsV2 *MetadataServiceV2) GetMetadataInfo(ctx
context.Context, req *triple
if err != nil {
return nil, err
}
+ if metadataInfo == nil {
+ return nil, nil
+ }
Review Comment:
Silent failure is not good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]