mirror of https://github.com/status-im/consul.git
Don't do any watch tracking for non-blocking queries.
This commit is contained in:
parent
05735e39a5
commit
fefed7c803
|
@ -464,10 +464,15 @@ RUN_QUERY:
|
|||
|
||||
// Run the query.
|
||||
metrics.IncrCounter([]string{"consul", "rpc", "query"}, 1)
|
||||
ws := memdb.NewWatchSet()
|
||||
err := fn(ws)
|
||||
|
||||
// We can skip all watch tracking if this isn't a blocking query.
|
||||
var ws memdb.WatchSet
|
||||
if queryOpts.MinQueryIndex > 0 {
|
||||
ws = memdb.NewWatchSet()
|
||||
}
|
||||
|
||||
// Block up to the timeout if we didn't see anything fresh.
|
||||
err := fn(ws)
|
||||
if err == nil && queryMeta.Index > 0 && queryMeta.Index <= queryOpts.MinQueryIndex {
|
||||
if expired := ws.Watch(timeout.C); !expired {
|
||||
goto RUN_QUERY
|
||||
|
|
Loading…
Reference in New Issue