From b1aa0dacb26e65e6b6b5c9e349f54acbad532f13 Mon Sep 17 00:00:00 2001 From: guoquanwei <31917049+guoquanwei@users.noreply.github.com> Date: Fri, 10 May 2024 17:05:23 +0800 Subject: [PATCH] Another implementation, the effect remains unchanged --- contrib/registry/nacos/watcher.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/registry/nacos/watcher.go b/contrib/registry/nacos/watcher.go index c60376697ce..7f1dc84663a 100644 --- a/contrib/registry/nacos/watcher.go +++ b/contrib/registry/nacos/watcher.go @@ -41,14 +41,16 @@ func newWatcher(ctx context.Context, cli naming_client.INamingClient, serviceNam Clusters: clusters, GroupName: groupName, SubscribeCallback: func(services []model.SubscribeService, err error) { - if len(w.watchChan) == 0 { - w.watchChan <- struct{}{} + select { + case w.watchChan <- struct{}{}: + default: } }, } e := w.cli.Subscribe(w.subscribeParam) - if len(w.watchChan) == 0 { - w.watchChan <- struct{}{} + select { + case w.watchChan <- struct{}{}: + default: } return w, e }