You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.
Hello
I see that consultdotnet supports Watches on KV pairs.
Is there support for other Watch types (services, nodes...)? Or, can this be implemented in some way (i.e. I missed something)?
Kind regards
Edward
The text was updated successfully, but these errors were encountered:
All query style requests (e.g. KV.Get, Catalog.Services, Health.Service, and many, many others) have a method signature that accepts a QueryOptions class parameter. QueryOptions objects are used to parameterize a query and have a WaitIndex property.
To watch an endpoint, first construct a QueryOptions class instance and leave WaitIndex at 0 (the default).
Pass the instance to a query method (e.g. client.Health.Service("fooservice", null, false, myQueryOpts)) and await the result. All queries return a QueryResult<T> object type. The Result property is the actual result of the query, but all the other properties of the QueryResult object have metadata about the query. What you're interested in is the LastIndex property of the QueryResult. Set you custom QueryOptions object's WaitIndex property to be the LastIndex value and re-issue your query. Your await will now block waiting for the query timeout or the blocking query to return when data is updated. See https://github.com/PlayFab/consuldotnet/blob/master/Consul/Lock.cs#L252-L308 for an actual example of use against the K/V store - this method works against any endpoint that supports blocking queries, though.
I really should write some better docs on how to use the API in C# since the way the HTTP API works diverges just enough to make the Hashicorp docs not quite work for this.
Okay, created #44 to track docs. Feel free to comment on that issue if there are any other docs you'd like to see that aren't covered by the Hashicorp docs on the operation of the service itself.
Let me know if you have any questions about this way of watching values or if not, feel free to close out the issue. Thanks!
Hello
I see that consultdotnet supports Watches on KV pairs.
Is there support for other Watch types (services, nodes...)? Or, can this be implemented in some way (i.e. I missed something)?
Kind regards
Edward
The text was updated successfully, but these errors were encountered: