github.com/Pankov404/juju@v0.0.0-20150703034450-be266991dceb/api/allwatcher.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package api 5 6 import ( 7 "github.com/juju/juju/api/base" 8 "github.com/juju/juju/apiserver/params" 9 "github.com/juju/juju/state/multiwatcher" 10 ) 11 12 // AllWatcher holds information allowing us to get Deltas describing changes 13 // to the entire environment. 14 type AllWatcher struct { 15 caller base.APICaller 16 id *string 17 } 18 19 func newAllWatcher(caller base.APICaller, id *string) *AllWatcher { 20 return &AllWatcher{caller, id} 21 } 22 23 func (watcher *AllWatcher) Next() ([]multiwatcher.Delta, error) { 24 var info params.AllWatcherNextResults 25 err := watcher.caller.APICall( 26 "AllWatcher", watcher.caller.BestFacadeVersion("AllWatcher"), 27 *watcher.id, "Next", nil, &info) 28 return info.Deltas, err 29 } 30 31 func (watcher *AllWatcher) Stop() error { 32 return watcher.caller.APICall( 33 "AllWatcher", watcher.caller.BestFacadeVersion("AllWatcher"), 34 *watcher.id, "Stop", nil, nil) 35 }