From c9d1e79e3860680a989872605f77925e19b3575f Mon Sep 17 00:00:00 2001 From: "b.goncalves" Date: Tue, 24 Jul 2018 15:51:07 +0100 Subject: [PATCH 1/2] Added meta dictionary to the service payloads of the agent API --- Consul/Agent.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Consul/Agent.cs b/Consul/Agent.cs index 0ea4673..1350f84 100644 --- a/Consul/Agent.cs +++ b/Consul/Agent.cs @@ -141,6 +141,7 @@ public class AgentService public int Port { get; set; } public string Address { get; set; } public bool EnableTagOverride { get; set; } + public IDictionary Meta { get; set; } } /// @@ -194,6 +195,9 @@ public class AgentServiceRegistration [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public AgentServiceCheck[] Checks { get; set; } + + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public IDictionary Meta { get; set; } } /// From ed9b8e156e5ace98c62d83f0b88e1a15db0f9db6 Mon Sep 17 00:00:00 2001 From: "b.goncalves" Date: Thu, 29 Nov 2018 10:42:32 +0000 Subject: [PATCH 2/2] Added ability to query for cached resources --- Consul/Client.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Consul/Client.cs b/Consul/Client.cs index 539ad84..1c23773 100644 --- a/Consul/Client.cs +++ b/Consul/Client.cs @@ -318,7 +318,8 @@ public class QueryOptions Consistency = ConsistencyMode.Default, Datacenter = string.Empty, Token = string.Empty, - WaitIndex = 0 + WaitIndex = 0, + Cached = false }; /// @@ -353,6 +354,13 @@ public class QueryOptions /// for the sort. /// public string Near { get; set; } + + /// + /// This query flag will tell the consul agent to return a cached resource, if the endpoint supports caching. + /// Some read endpoints support agent caching. They are clearly marked in the documentation. Agent caching can take two forms, simple or background refresh depending on the endpoint's semantics. + /// https://www.consul.io/api/index.html + /// + public bool Cached { get; set; } } /// @@ -1045,6 +1053,10 @@ protected override void ApplyOptions(ConsulClientConfiguration clientConfig) { Params["near"] = Options.Near; } + if (Options.Cached) + { + Params["cached"] = string.Empty; + } } protected void ParseQueryHeaders(HttpResponseMessage res, QueryResult meta)