dockerclient icon indicating copy to clipboard operation
dockerclient copied to clipboard

StartMonitorEvents is not idiomatic

Open daaku opened this issue 11 years ago • 0 comments

StartMonitorEvents takes a callback, and a channel, and untyped args. It spins up a new goroutine per call, but shares an atomic to allow StopAllMonitorEvents to work. The whole thing just seems very messy.

https://github.com/go-fsnotify/fsnotify may be a good source of inspiration here.

Would prefer an API along the lines of:

type Watcher struct {
  Error chan error
  Event chan *Event
}

func (w *Watcher) Close() error {
  ...
}

func (d *DockerClient) Watcher() (*Watcher, error) {
}

The Start/Stop can go away. Internally a single HTTP stream can be used for all the Watchers. Each Watcher can provide a Close so a global Stop/Close isn't necessary.

Thoughts?

daaku avatar Feb 05 '15 23:02 daaku