storage: add watch ID to identify watchings

One watcher includes multiple watchings, and their events are
sent out through one channel. For the received event, user would like to
know which watching it belongs to.

Introduce a watch ID. When watching on some key, user will get a watch
ID. The watch ID is attached to all events that is observed by this
watch.
This commit is contained in:
Yicheng Qin
2015-11-20 10:50:53 -08:00
parent 2de9a5bbd0
commit deb1da5f57
8 changed files with 125 additions and 16 deletions

View File

@ -49,7 +49,7 @@ func TestNewWatcherCancel(t *testing.T) {
s.Put(testKey, testValue)
w := s.NewWatcher()
cancel := w.Watch(testKey, true, 0)
_, cancel := w.Watch(testKey, true, 0)
cancel()