Documentation ¶
Index ¶
Constants ¶
const ( All = ActionsMask(0) Create = ActionsMask(1) Update = ActionsMask(2) Delete = ActionsMask(4) Moved = ActionsMask(8) )
Possible ActionTypes (powers of two for bitwise arithmetic)
Variables ¶
var Log = logging.Log.New("pkg", "notif")
Log is used to log messages for the sift package. Logs are disabled by default; use sift/logging.SetLevel() to set log levels for all packages, or Log.SetHandler() to set a custom handler for this package (see: https://godoc.org/gopkg.in/inconshreveable/log15.v2)
Functions ¶
This section is empty.
Types ¶
type ActionsMask ¶
type ActionsMask uint8
An ActionsMask represents actions which may trigger a notification.
func (ActionsMask) String ¶
func (a ActionsMask) String() string
String returns a human-readable string representation of the ActionsMask
type ComponentFilter ¶
type ComponentFilter struct { ID types.ComponentID Type string Actions ActionsMask }
A ComponentFilter is used by a listener to select noficiations from specific Components. Nil values are interpreted as "don't care".
type ComponentNotification ¶
type ComponentNotification struct { ID types.ComponentID Component types.Component Action ActionsMask }
A ComponentNotification describes a change to a single Component
type ComponentNotifier ¶
type ComponentNotifier interface {
PostComponent(id types.ComponentID, comp types.Component, amask ActionsMask)
}
A ComponentNotifier can notify listeners of changes to Components
type DeviceFilter ¶
type DeviceFilter struct { ID types.DeviceID Actions ActionsMask }
A DeviceFilter is used by a listener to select noficiations from specific Devices. Nil values are interpreted as "don't care".
type DeviceNotification ¶
type DeviceNotification struct { ID types.DeviceID Device types.Device Action ActionsMask }
A DeviceNotification describes a change to a single Device
type DeviceNotifier ¶
type DeviceNotifier interface {
PostDevice(id types.DeviceID, dev types.Device, atype ActionsMask)
}
A DeviceNotifier can notify listeners of changes to Devices
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
A Notifier implements ProviderReceiver. It provides methods for listeners to listen for notifications, as well as methods to post notifications to listeners.
func (*Notifier) Listen ¶
Listen returns a channel which will be populated with notifications from the notifier. If one or more filters are provided, only notifications matching those filters will populate the channel. If no filters are provided, all notifications will populate the channel.
func (*Notifier) PostComponent ¶
func (n *Notifier) PostComponent(id types.ComponentID, comp types.Component, amask ActionsMask)
PostComponent will notify all listeners of a change to the provided Component. The specific type of change should by provided in the ActionsMask.
func (*Notifier) PostDevice ¶
PostDevice will notify all listeners of a change to the provided Device. The specific type of change should by provided in the ActionsMask.
type ProviderReceiver ¶
A ProviderReceiver provides methods for listeners to listen for notifications, as well as methods to post notifications to listeners.
type Receiver ¶
type Receiver interface { ComponentNotifier DeviceNotifier }
A Receiver provides methods for posting notifications to listeners