mirror of
https://github.com/alibaba/higress.git
synced 2026-05-25 05:07:26 +08:00
fix: refactored mcp server auto discovery logic and fix some issue (#2382)
Co-authored-by: johnlanni <zty98751@alibaba-inc.com>
This commit is contained in:
@@ -36,7 +36,6 @@ import (
|
||||
"github.com/alibaba/higress/registry/eureka"
|
||||
"github.com/alibaba/higress/registry/memory"
|
||||
"github.com/alibaba/higress/registry/nacos"
|
||||
"github.com/alibaba/higress/registry/nacos/mcpserver"
|
||||
nacosv2 "github.com/alibaba/higress/registry/nacos/v2"
|
||||
"github.com/alibaba/higress/registry/zookeeper"
|
||||
)
|
||||
@@ -171,7 +170,7 @@ func (r *Reconciler) generateWatcherFromRegistryConfig(registry *apiv1.RegistryC
|
||||
nacos.WithNacosRefreshInterval(registry.NacosRefreshInterval),
|
||||
nacos.WithAuthOption(authOption),
|
||||
)
|
||||
case string(Nacos2):
|
||||
case string(Nacos2), string(Nacos3):
|
||||
watcher, err = nacosv2.NewWatcher(
|
||||
r.Cache,
|
||||
nacosv2.WithType(registry.Type),
|
||||
@@ -185,44 +184,13 @@ func (r *Reconciler) generateWatcherFromRegistryConfig(registry *apiv1.RegistryC
|
||||
nacosv2.WithNacosNamespace(registry.NacosNamespace),
|
||||
nacosv2.WithNacosGroups(registry.NacosGroups),
|
||||
nacosv2.WithNacosRefreshInterval(registry.NacosRefreshInterval),
|
||||
nacosv2.WithMcpExportDomains(registry.McpServerExportDomains),
|
||||
nacosv2.WithMcpBaseUrl(registry.McpServerBaseUrl),
|
||||
nacosv2.WithEnableMcpServer(registry.EnableMCPServer),
|
||||
nacosv2.WithClusterId(r.clusterId),
|
||||
nacosv2.WithNamespace(r.namespace),
|
||||
nacosv2.WithAuthOption(authOption),
|
||||
)
|
||||
case string(Nacos3):
|
||||
if registry.EnableMCPServer.GetValue() {
|
||||
watcher, err = mcpserver.NewWatcher(
|
||||
r.Cache,
|
||||
mcpserver.WithType(registry.Type),
|
||||
mcpserver.WithName(registry.Name),
|
||||
mcpserver.WithNacosAddressServer(registry.NacosAddressServer),
|
||||
mcpserver.WithDomain(registry.Domain),
|
||||
mcpserver.WithPort(registry.Port),
|
||||
mcpserver.WithNacosAccessKey(registry.NacosAccessKey),
|
||||
mcpserver.WithNacosSecretKey(registry.NacosSecretKey),
|
||||
mcpserver.WithNacosRefreshInterval(registry.NacosRefreshInterval),
|
||||
mcpserver.WithMcpExportDomains(registry.McpServerExportDomains),
|
||||
mcpserver.WithMcpBaseUrl(registry.McpServerBaseUrl),
|
||||
mcpserver.WithEnableMcpServer(registry.EnableMCPServer),
|
||||
mcpserver.WithClusterId(r.clusterId),
|
||||
mcpserver.WithNamespace(r.namespace),
|
||||
mcpserver.WithAuthOption(authOption),
|
||||
)
|
||||
} else {
|
||||
watcher, err = nacosv2.NewWatcher(
|
||||
r.Cache,
|
||||
nacosv2.WithType(registry.Type),
|
||||
nacosv2.WithName(registry.Name),
|
||||
nacosv2.WithNacosAddressServer(registry.NacosAddressServer),
|
||||
nacosv2.WithDomain(registry.Domain),
|
||||
nacosv2.WithPort(registry.Port),
|
||||
nacosv2.WithNacosAccessKey(registry.NacosAccessKey),
|
||||
nacosv2.WithNacosSecretKey(registry.NacosSecretKey),
|
||||
nacosv2.WithNacosNamespaceId(registry.NacosNamespaceId),
|
||||
nacosv2.WithNacosNamespace(registry.NacosNamespace),
|
||||
nacosv2.WithNacosGroups(registry.NacosGroups),
|
||||
nacosv2.WithNacosRefreshInterval(registry.NacosRefreshInterval),
|
||||
nacosv2.WithAuthOption(authOption),
|
||||
)
|
||||
}
|
||||
case string(Zookeeper):
|
||||
watcher, err = zookeeper.NewWatcher(
|
||||
r.Cache,
|
||||
|
||||
Reference in New Issue
Block a user