mochengqian commented on code in PR #953:
URL: https://github.com/apache/dubbo-go-pixiu/pull/953#discussion_r3489051749


##########
pkg/adapter/mcpserver/registrycenter.go:
##########
@@ -157,47 +158,18 @@ func (a *Adapter) Apply() error {
                        continue
                }
 
+               reconciler := a.endpoints
+               if reconciler == nil {
+                       reconciler = 
newEndpointReconciler(clusterManagerEndpointSink{})
+                       a.endpoints = reconciler
+               }
+               registryName := k
+               sink, err := a.bindPublicationSink()
+               if err != nil {
+                       logger.Infof("[dubbo-go-pixiu] mcp adapter registry %s 
has no bound runtime publication sink: %v", registryName, err)
+               }
                onChange := func(serverId string, cfg *model.McpServerConfig) {
-                       if cfg == nil {
-                               return
-                       }
-
-                       if serverId == "" {
-                               serverId = "default"
-                       }
-
-                       // 1) apply tools dynamically to registry for filter 
usage
-                       if dc := mcpserver.GetOrInitDynamicConsumer(); dc != 
nil {
-                               if err := 
dc.ApplyMcpServerConfigByServer(serverId, cfg); err != nil {
-                                       logger.Errorf("[dubbo-go-pixiu] mcp 
adapter apply server %s config error: %v", serverId, err)
-                               }
-                       } else {
-                               logger.Infof("[dubbo-go-pixiu] mcp adapter 
update received from server %s: tools=%d", serverId, len(cfg.Tools))
-                       }
-                       // 2) register endpoint for each tool using BackendURL 
(host:port) into cluster named by tool.Name
-                       for _, tool := range cfg.Tools {
-                               if tool.BackendURL == "" {
-                                       continue
-                               }
-                               result, err := 
util.ParseHostPortFromURL(tool.BackendURL)
-                               if err != nil {
-                                       logger.Errorf("[dubbo-go-pixiu] mcp 
adapter failed to parse BackendURL '%s' for tool '%s': %v",
-                                               tool.BackendURL, tool.Name, err)
-                                       continue
-                               }
-                               if result.UsedFallback {
-                                       logger.Warnf("[dubbo-go-pixiu] mcp 
adapter using fallback for tool '%s' with BackendURL '%s': %s",
-                                               tool.Name, tool.BackendURL, 
result.FallbackInfo)
-                               }
-                               endpointID := result.Host + ":" + 
strconv.Itoa(result.Port)
-                               
server.GetClusterManager().SetEndpoint(tool.Cluster, &model.Endpoint{
-                                       ID: endpointID,
-                                       Address: model.SocketAddress{
-                                               Address: result.Host,
-                                               Port:    result.Port,
-                                       },
-                               })
-                       }
+                       a.applyServerConfigEvent(reconciler, sink, 
registryName, serverId, cfg)

Review Comment:
   fixed



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