AlexStocks commented on code in PR #2983:
URL: https://github.com/apache/dubbo-go/pull/2983#discussion_r2296838589


##########
metadata/metadata_service.go:
##########
@@ -148,27 +148,70 @@ type serviceExporter struct {
        v2Exporter       base.Exporter
 }
 
-// Export will export the metadataService
+// Export will export metadata services using single port dual interface 
architecture
+// This ensures compatibility and proper client discovery for both V1 and V2
 func (e *serviceExporter) Export() error {
-       var port string
-       if e.opts.port == 0 {
-               port = common.GetRandomPort("")
-       } else {
-               port = strconv.Itoa(e.opts.port)
+       port := e.getPort()
+
+       // Export V1 protocol for backward compatibility
+       if err := e.exportV1Services(port); err != nil {
+               return err
        }
-       if e.opts.protocol == constant.DefaultProtocol {
-               err := e.exportDubbo(port)
-               if err != nil {
-                       return err
+
+       // Export V2 protocol on same port with different interface name
+       // Only export V2 for tri protocol to maintain compatibility
+       if e.shouldExportV2() {
+               if err := e.exportV2Services(port); err != nil {
+                       // Log warning but don't fail - V1 should continue 
working
+                       logger.Warnf("Failed to export MetadataService V2: %v", 
err)
                }
-       } else {
-               e.exportTripleV1(port)
-               // v2 only supports triple protocol
-               e.exportV2(port)
        }
+
        return nil
 }
 
+// shouldExportV2 determines if V2 protocol should be exported
+// Only export V2 for tri protocol to avoid serialization conflicts
+func (e *serviceExporter) shouldExportV2() bool {
+       return e.opts.protocol == constant.TriProtocol

Review Comment:
   这种一行代码的函数就没必要了吧?



-- 
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]

Reply via email to