mvcc/watchable_store.go
func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
	var victim watcherBatch
	for w, eb := range newWatcherBatch(&s.synced, evs) {
		if eb.revs != 1 {
			if s.store != nil && s.store.lg != nil {
				s.store.lg.Panic(
					"unexpected multiple revisions in watch notification",
					zap.Int("number-of-revisions", eb.revs),
				)
			} else {
				plog.Panicf("unexpected multiple revisions in notification")
			}
		}
		if w.send(WatchResponse{WatchID: w.id, Events: eb.evs, Revision: rev}) {
			pendingEventsGauge.Add(float64(len(eb.evs)))
		} else {
			// move slow watcher to victims
			w.minRev = rev + 1
			if victim == nil {
				victim = make(watcherBatch)
			}
			w.victim = true
			victim[w] = eb
			s.synced.delete(w)
			slowWatcherGauge.Inc()
		}
	}
	s.addVictim(victim)
}
func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
	var victim watcherBatch
	for w, eb := range newWatcherBatch(&s.synced, evs) {
		if eb.revs != 1 {
			if s.store != nil && s.store.lg != nil {
				s.store.lg.Panic(
					"unexpected multiple revisions in watch notification",
					zap.Int("number-of-revisions", eb.revs),
				)
			} else {
				plog.Panicf("unexpected multiple revisions in notification")
			}
		}
		if w.send(WatchResponse{WatchID: w.id, Events: eb.evs, Revision: rev}) {
			pendingEventsGauge.Add(float64(len(eb.evs)))
		} else {
			// move slow watcher to victims
			w.minRev = rev + 1
			if victim == nil {
				victim = make(watcherBatch)
			}
			w.victim = true
			victim[w] = eb
			s.synced.delete(w)
			slowWatcherGauge.Inc()
		}
	}
	s.addVictim(victim)
}
func ( s * watchableStore ) notify ( rev int64 , evs [ ] mvccpb . Event ) { var victim watcherBatch for w , eb := range newWatcherBatch ( & s . synced , evs ) { if eb . revs != 1 { if s . store != nil && s . store . lg != nil { s . store . lg . Panic ( " " , zap . Int ( " " , eb . revs ) , ) } else { plog . Panicf ( " " ) } } if w . send ( WatchResponse { WatchID : w . id , Events : eb . evs , Revision : rev } ) { pendingEventsGauge . Add ( float64 ( len ( eb . evs ) ) ) } else { // move slow watcher to victims w . minRev = rev + 1 if victim == nil { victim = make ( watcherBatch ) } w . victim = true victim [ w ] = eb s . synced . delete ( w ) slowWatcherGauge . Inc ( ) } } s . addVictim ( victim ) }
// notify notifies the fact that given event at the given rev just happened to
// watchers that watch on the key of the event.
notify notifies the fact that given event at the given rev just happened to watchers that watch on the key of the event .