|
|
@@ -50,27 +50,20 @@ func newWatchBroadcast(wp *watchProxy, w *watcher, update func(*watchBroadcast))
|
|
|
wb.add(w)
|
|
|
go func() {
|
|
|
defer close(wb.donec)
|
|
|
- // loop because leader loss will close channel
|
|
|
- for cctx.Err() == nil {
|
|
|
- opts := []clientv3.OpOption{
|
|
|
- clientv3.WithRange(w.wr.end),
|
|
|
- clientv3.WithProgressNotify(),
|
|
|
- clientv3.WithRev(wb.nextrev),
|
|
|
- clientv3.WithPrevKV(),
|
|
|
- }
|
|
|
- // The create notification should be the first response;
|
|
|
- // if the watch is recreated following leader loss, it
|
|
|
- // shouldn't post a second create response to the client.
|
|
|
- if wb.responses == 0 {
|
|
|
- opts = append(opts, clientv3.WithCreatedNotify())
|
|
|
- }
|
|
|
- wch := wp.cw.Watch(cctx, w.wr.key, opts...)
|
|
|
-
|
|
|
- for wr := range wch {
|
|
|
- wb.bcast(wr)
|
|
|
- update(wb)
|
|
|
- }
|
|
|
- wp.retryLimiter.Wait(cctx)
|
|
|
+
|
|
|
+ opts := []clientv3.OpOption{
|
|
|
+ clientv3.WithRange(w.wr.end),
|
|
|
+ clientv3.WithProgressNotify(),
|
|
|
+ clientv3.WithRev(wb.nextrev),
|
|
|
+ clientv3.WithPrevKV(),
|
|
|
+ clientv3.WithCreatedNotify(),
|
|
|
+ }
|
|
|
+
|
|
|
+ wch := wp.cw.Watch(cctx, w.wr.key, opts...)
|
|
|
+
|
|
|
+ for wr := range wch {
|
|
|
+ wb.bcast(wr)
|
|
|
+ update(wb)
|
|
|
}
|
|
|
}()
|
|
|
return wb
|