multiwatcher

package
v0.0.0-...-acd7349 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2013 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 InfoId

type InfoId interface{}

InfoId holds an identifier for an Info item held in a Store.

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

func (a *Store) ChangesSince(revno int64) []params.Delta

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

func (a *Store) Remove(id params.EntityId)

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.

func (*StoreManager) Stop

func (sm *StoreManager) Stop() error

Stop stops the StoreManager.

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.

func (*Watcher) Next

func (w *Watcher) Next() ([]params.Delta, error)

Next retrieves all changes that have happened since the last time it was called, blocking until there are some changes available.

func (*Watcher) Stop

func (w *Watcher) Stop() error

Stop stops the watcher.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL