From f31de6d940a5406765d4ec6410b88324ab06ac5f Mon Sep 17 00:00:00 2001
From: yilei <87119538@qq.com>
Date: Wed, 25 Aug 2021 19:01:40 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Consul=20PollForChanges?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Grpc.Extension.Client/Options/JaegerOptions.cs | 2 +-
src/Grpc.Extension.Discovery/Consul/ConsulServiceDiscovery.cs | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/Grpc.Extension.Client/Options/JaegerOptions.cs b/src/Grpc.Extension.Client/Options/JaegerOptions.cs
index 90970dc..9473f7d 100644
--- a/src/Grpc.Extension.Client/Options/JaegerOptions.cs
+++ b/src/Grpc.Extension.Client/Options/JaegerOptions.cs
@@ -12,7 +12,7 @@ public class JaegerOptions
///
/// 是否启用Jaeger
///
- public bool Enable { get; set; } = true;
+ public bool Enable { get; set; }
///
/// 服务名
diff --git a/src/Grpc.Extension.Discovery/Consul/ConsulServiceDiscovery.cs b/src/Grpc.Extension.Discovery/Consul/ConsulServiceDiscovery.cs
index 0a7c6ec..f5f22cd 100644
--- a/src/Grpc.Extension.Discovery/Consul/ConsulServiceDiscovery.cs
+++ b/src/Grpc.Extension.Discovery/Consul/ConsulServiceDiscovery.cs
@@ -31,7 +31,8 @@ public async Task> GetEndpoints(string serviceName, string consulUr
//更新LastIndex
UpdateLastIndex(serviceName, res);
//PollForChanges
- _ = Task.Run(() => PollForChanges(serviceName, consulUrl, consulTag));
+ if (!_pollForChanges.Contains(serviceName))
+ _ = Task.Run(() => PollForChanges(serviceName, consulUrl, consulTag));
return res.Response.Select(q => $"{q.Service.Address}:{q.Service.Port}").ToList();
}