Watch should start from next index when getting the initial state

Also, the fake response we return should have an Action that is
appropriate for the operation.
This commit is contained in:
Clayton Coleman
2014-08-14 15:51:56 -04:00
parent 778c89f65e
commit 7c67cbff04
2 changed files with 33 additions and 41 deletions

View File

@@ -419,11 +419,11 @@ func etcdGetInitialWatchState(client EtcdGetSet, key string, recursive bool, inc
return
}
if index, ok := etcdErrorIndex(err); ok {
resourceVersion = index
resourceVersion = index + 1
}
return
}
resourceVersion = resp.EtcdIndex
resourceVersion = resp.EtcdIndex + 1
convertRecursiveResponse(resp.Node, resp, incoming)
return
}
@@ -438,6 +438,11 @@ func convertRecursiveResponse(node *etcd.Node, response *etcd.Response, incoming
return
}
copied := *response
if node.ModifiedIndex == node.CreatedIndex {
copied.Action = "create"
} else {
copied.Action = "set"
}
copied.Node = node
incoming <- &copied
}