*: update watch related proto

1. Add watch/cancel request
2. Add necessary fields in response to return watch error
3. Add watch_id into watch response
This commit is contained in:
Xiang Li
2015-12-31 22:28:54 -08:00
parent 7dd599b69d
commit ac330bb7c9
5 changed files with 477 additions and 30 deletions

View File

@ -48,14 +48,20 @@ func (ws *watchServer) Watch(stream pb.Watch_WatchServer) error {
return err
}
var prefix bool
toWatch := req.Key
if len(req.Key) == 0 {
toWatch = req.Prefix
prefix = true
switch {
case req.CreateRequest != nil:
creq := req.CreateRequest
var prefix bool
toWatch := creq.Key
if len(creq.Key) == 0 {
toWatch = creq.Prefix
prefix = true
}
watcher.Watch(toWatch, prefix, creq.StartRevision)
default:
// TODO: support cancellation
panic("not implemented")
}
// TODO: support cancellation
watcher.Watch(toWatch, prefix, req.StartRevision)
}
}