mirror of
https://github.com/alibaba/higress.git
synced 2026-06-09 20:57:32 +08:00
When the service source type is nacos3, if mcpserver is turned off, then the discovery mechanism of nacos2 will be enabled (#2150)
This commit is contained in:
@@ -111,9 +111,10 @@ func NewWatcher(cache memory.Cache, opts ...WatcherOption) (provider.Watcher, er
|
|||||||
opt(w)
|
opt(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
if w.NacosNamespace == "" {
|
// The nacos mcp server uses these restricted namespaces and groups, and may be adjusted in the future.
|
||||||
w.NacosNamespace = w.NacosNamespaceId
|
w.NacosNamespace = "nacos-default-mcp"
|
||||||
}
|
w.NacosNamespaceId = w.NacosNamespace
|
||||||
|
w.NacosGroups = []string{"mcp-server"}
|
||||||
|
|
||||||
mcpServerLog.Infof("new nacos mcp server watcher with config Name:%s", w.Name)
|
mcpServerLog.Infof("new nacos mcp server watcher with config Name:%s", w.Name)
|
||||||
|
|
||||||
@@ -177,32 +178,6 @@ func WithNacosSecretKey(nacosSecretKey string) WatcherOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithNacosNamespaceId(nacosNamespaceId string) WatcherOption {
|
|
||||||
return func(w *watcher) {
|
|
||||||
if nacosNamespaceId == "" {
|
|
||||||
w.NacosNamespaceId = "nacos-default-mcp"
|
|
||||||
} else {
|
|
||||||
w.NacosNamespaceId = nacosNamespaceId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithNacosNamespace(nacosNamespace string) WatcherOption {
|
|
||||||
return func(w *watcher) {
|
|
||||||
w.NacosNamespace = nacosNamespace
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithNacosGroups(nacosGroups []string) WatcherOption {
|
|
||||||
return func(w *watcher) {
|
|
||||||
if len(nacosGroups) == 0 {
|
|
||||||
w.NacosGroups = []string{"mcp-server"}
|
|
||||||
} else {
|
|
||||||
w.NacosGroups = nacosGroups
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func WithNacosRefreshInterval(refreshInterval int64) WatcherOption {
|
func WithNacosRefreshInterval(refreshInterval int64) WatcherOption {
|
||||||
return func(w *watcher) {
|
return func(w *watcher) {
|
||||||
if refreshInterval < int64(DefaultRefreshIntervalLimit) {
|
if refreshInterval < int64(DefaultRefreshIntervalLimit) {
|
||||||
@@ -967,7 +942,8 @@ func (w *watcher) Stop() {
|
|||||||
}
|
}
|
||||||
mcpServerLog.Infof("stop all service nameing client")
|
mcpServerLog.Infof("stop all service nameing client")
|
||||||
for _, client := range w.serviceCache {
|
for _, client := range w.serviceCache {
|
||||||
client.Stop()
|
// TODO: This is a temporary implementation because of a bug in the nacos-go-sdk, which causes a block when stoping.
|
||||||
|
go client.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
w.isStop = true
|
w.isStop = true
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ func (r *Reconciler) generateWatcherFromRegistryConfig(registry *apiv1.RegistryC
|
|||||||
nacosv2.WithAuthOption(authOption),
|
nacosv2.WithAuthOption(authOption),
|
||||||
)
|
)
|
||||||
case string(Nacos3):
|
case string(Nacos3):
|
||||||
|
if registry.EnableMCPServer.GetValue() {
|
||||||
watcher, err = mcpserver.NewWatcher(
|
watcher, err = mcpserver.NewWatcher(
|
||||||
r.Cache,
|
r.Cache,
|
||||||
mcpserver.WithType(registry.Type),
|
mcpserver.WithType(registry.Type),
|
||||||
@@ -196,9 +197,6 @@ func (r *Reconciler) generateWatcherFromRegistryConfig(registry *apiv1.RegistryC
|
|||||||
mcpserver.WithPort(registry.Port),
|
mcpserver.WithPort(registry.Port),
|
||||||
mcpserver.WithNacosAccessKey(registry.NacosAccessKey),
|
mcpserver.WithNacosAccessKey(registry.NacosAccessKey),
|
||||||
mcpserver.WithNacosSecretKey(registry.NacosSecretKey),
|
mcpserver.WithNacosSecretKey(registry.NacosSecretKey),
|
||||||
mcpserver.WithNacosNamespaceId(registry.NacosNamespaceId),
|
|
||||||
mcpserver.WithNacosNamespace(registry.NacosNamespace),
|
|
||||||
mcpserver.WithNacosGroups(registry.NacosGroups),
|
|
||||||
mcpserver.WithNacosRefreshInterval(registry.NacosRefreshInterval),
|
mcpserver.WithNacosRefreshInterval(registry.NacosRefreshInterval),
|
||||||
mcpserver.WithMcpExportDomains(registry.McpServerExportDomains),
|
mcpserver.WithMcpExportDomains(registry.McpServerExportDomains),
|
||||||
mcpserver.WithMcpBaseUrl(registry.McpServerBaseUrl),
|
mcpserver.WithMcpBaseUrl(registry.McpServerBaseUrl),
|
||||||
@@ -206,6 +204,23 @@ func (r *Reconciler) generateWatcherFromRegistryConfig(registry *apiv1.RegistryC
|
|||||||
mcpserver.WithClusterId(r.clusterId),
|
mcpserver.WithClusterId(r.clusterId),
|
||||||
mcpserver.WithNamespace(r.namespace),
|
mcpserver.WithNamespace(r.namespace),
|
||||||
)
|
)
|
||||||
|
} 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):
|
case string(Zookeeper):
|
||||||
watcher, err = zookeeper.NewWatcher(
|
watcher, err = zookeeper.NewWatcher(
|
||||||
r.Cache,
|
r.Cache,
|
||||||
|
|||||||
Reference in New Issue
Block a user