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
Watching events can result in more than one events being returned
After a bit of digging I've found that it seems to be that the index's aren't sequential
watch.eventWatch calls which calls event.List which loads a lastindex from the meta that is returned to plan.Run
// If the index is unchanged do nothing
if index == p.lastIndex {
continue
}
// Update the index, look for change
oldIndex := p.lastIndex
p.lastIndex = index
if oldIndex != 0 && reflect.DeepEqual(p.lastResult, result) {
continue
}
// This if is the problem, it assumes sequential indexing...
// if p.lastIndex < oldIndex {
// p.lastIndex = 0
// }
Reproduction steps
I simply wrote a tiny go client
package main
import (
"fmt"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/watch"
)
func main() {
w, _ := watch.Parse(map[string]interface{}{
"type": "event",
"name": "deploy-router",
})
w.Handler = func(a uint64, b interface{}) {
if list, ok := b.([]*api.UserEvent); ok {
fmt.Println("got", len(list))
}
}
w.Run("localhost:8500")
}
and ran consul in docker, sending events in.
When I comment out that if it behaves as expected only returning one event
The text was updated successfully, but these errors were encountered:
consul version
for both Client and ServerClient: Consul v0.9.2
Server: Consul v0.9.2
consul info
for both Client and ServerServer:
Operating system and Environment details
MacOS, Ubuntu, Docker
Description of the Issue (and unexpected/desired result)
Using the go api for watches
Watching events can result in more than one events being returned
After a bit of digging I've found that it seems to be that the index's aren't sequential
watch.eventWatch calls which calls event.List which loads a lastindex from the meta that is returned to plan.Run
Reproduction steps
I simply wrote a tiny go client
and ran consul in docker, sending events in.
When I comment out that if it behaves as expected only returning one event
The text was updated successfully, but these errors were encountered: