示例#1
0
// Watch watches a given object for changes.
func (c *Client) Watch(obj db.Entity) (chan db.Entity, chan error) {
	path, err := obj.Path()
	if err != nil {
		errChan := make(chan error, 1)
		errChan <- err
		return nil, errChan
	}

	return helpers.WrapWatch(c, obj, path, false, c.watchers, &c.watcherMutex, c.startWatch)
}
示例#2
0
// Watch watches stuff.
func (c *Client) Watch(obj db.Entity) (chan db.Entity, chan error) {
	path, err := obj.Path()
	if err != nil {
		errChan := make(chan error, 1)
		errChan <- err
		return nil, errChan
	}

	// these paths are qualified in watchInternal
	return helpers.WrapWatch(c, obj, path, false, c.watchers, &c.watcherMutex, c.watchInternal)
}
示例#3
0
// WatchPrefix watches a directory prefix for changes.
func (c *Client) WatchPrefix(obj db.Entity) (chan db.Entity, chan error) {
	// these paths are qualified in watchInternal
	return helpers.WrapWatch(c, obj, obj.Prefix(), true, c.watchers, &c.watcherMutex, c.watchInternal)
}
示例#4
0
// WatchPrefix watches all items under the given entity's prefix
func (c *Client) WatchPrefix(obj db.Entity) (chan db.Entity, chan error) {
	return helpers.WrapWatch(c, obj, obj.Prefix(), true, c.watchers, &c.watcherMutex, c.startWatch)
}