Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrWatcherStopped = errors.New("state watcher was stopped")
Functions ¶
This section is empty.
Types ¶
type Backing ¶
type Backing interface { // GetAll retrieves information about all information // known to the Backing and stashes it in the Store. GetAll(all *Store) error // Changed informs the backing about a change received // from a watcher channel. The backing is responsible for // updating the Store to reflect the change. Changed(all *Store, change watcher.Change) error // Watch watches for any changes and sends them // on the given channel. Watch(in chan<- watcher.Change) // Unwatch stops watching for changes on the // given channel. Unwatch(in chan<- watcher.Change) }
Backing is the interface required by the StoreManager to access the underlying state.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds a list of all entities known to a Watcher.
func NewStore ¶
func NewStore() *Store
NewStore returns an Store instance holding information about the current state of all entities in the environment. It is only exposed here for testing purposes.
func (*Store) All ¶
func (a *Store) All() []params.EntityInfo
All returns all the entities stored in the Store, oldest first. It is only exposed for testing purposes.
func (*Store) ChangesSince ¶
ChangesSince returns any changes that have occurred since the given revno, oldest first.
func (*Store) Get ¶
func (a *Store) Get(id params.EntityId) params.EntityInfo
Get returns the stored entity with the given id, or nil if none was found. The contents of the returned entity should not be changed.
func (*Store) Remove ¶
Remove marks that the entity with the given id has been removed from the backing. If nothing has seen the entity, then we delete it immediately.
func (*Store) Update ¶
func (a *Store) Update(info params.EntityInfo)
Update updates the information for the given entity.
type StoreManager ¶
type StoreManager struct {
// contains filtered or unexported fields
}
StoreManager holds a shared record of current state and replies to requests from Watchers to tell them when it changes.
func NewStoreManager ¶
func NewStoreManager(backing Backing) *StoreManager
NewStoreManager returns a new StoreManager that retrieves information using the given backing.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
Watcher watches any changes to the state.
func NewWatcher ¶
func NewWatcher(all *StoreManager) *Watcher
NewWatcher creates a new watcher that can observe changes to an underlying store manager.