code: func (c *CircularBuffer) NewWatcher(ctx context.Context, watch Watch) (Watcher, error) {
  	c.Lock()
  	defer c.Unlock()
  
  	select {
  	case <-c.ctx.Done():
  		return nil, trace.BadParameter("buffer is closed")
  	default:
  	}
  
  	if watch.QueueSize == 0 {
  		watch.QueueSize = len(c.events)
  	}
  
  	if len(watch.Prefixes) == 0 {
  		// if watcher has no prefixes, assume it will match anything
  		// starting from the separator (what includes all keys in backend invariant, see Keys function)
  		watch.Prefixes = append(watch.Prefixes, []byte{Separator})
  	} else {
  		// if watcher's prefixes are redundant, keep only shorter prefixes
  		// to avoid double fan out
  		watch.Prefixes = removeRedundantPrefixes(watch.Prefixes)
  	}
  
  	closeCtx, cancel := context.WithCancel(ctx)
  	w := &BufferWatcher{
  		Watch:    watch,
  		eventsC:  make(chan Event, watch.QueueSize),
  		ctx:      closeCtx,
  		cancel:   cancel,
  		capacity: watch.QueueSize,
  	}
  	c.Debugf("Add %v.", w)
  	select {
  	case w.eventsC <- Event{Type: OpInit}:
  	case <-c.ctx.Done():
  		return nil, trace.BadParameter("buffer is closed")
  	default:
  		c.Warningf("Closing %v, buffer overflow.", w)
  		w.Close()
  		return nil, trace.BadParameter("buffer overflow")
  	}
  	c.watchers.add(w)
  	return w, nil
  }
docs: // NewWatcher adds a new watcher to the events buffer