src/server/pkg/collection/collection.go
func (c *readonlyCollection) WatchOneF(key string, f func(e *watch.Event) error) error {
	watcher, err := watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.Path(key), c.template)
	if err != nil {
		return err
	}
	defer watcher.Close()
	for {
		select {
		case e := <-watcher.Watch():
			if err := f(e); err != nil {
				if err == errutil.ErrBreak {
					return nil
				}
				return err
			}
		case <-c.ctx.Done():
			return c.ctx.Err()
		}
	}
}
func (c *readonlyCollection) WatchOneF(key string, f func(e *watch.Event) error) error {
	watcher, err := watch.NewWatcher(c.ctx, c.etcdClient, c.prefix, c.Path(key), c.template)
	if err != nil {
		return err
	}
	defer watcher.Close()
	for {
		select {
		case e := <-watcher.Watch():
			if err := f(e); err != nil {
				if err == errutil.ErrBreak {
					return nil
				}
				return err
			}
		case <-c.ctx.Done():
			return c.ctx.Err()
		}
	}
}
// WatchOneF watches a given item and executes a callback function each time an event occurs.
// The first value returned from the watch will be the current value of the item.