notif

package
v0.0.0-...-b0e10ae Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

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

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

func New(authorizor auth.Authorizor) *Notifier

New creates a new notifier.

func (*Notifier) Listen

func (n *Notifier) Listen(token auth.Token, filters ...interface{}) <-chan interface{}

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

func (n *Notifier) PostDevice(id types.DeviceID, dev types.Device, atype ActionsMask)

PostDevice will notify all listeners of a change to the provided Device. The specific type of change should by provided in the ActionsMask.

type Provider

type Provider interface {
	Listen(auth.Token, ...interface{}) <-chan interface{}
}

A Provider provides methods for listeners to listen for notifications

type ProviderReceiver

type ProviderReceiver interface {
	Provider
	Receiver
}

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

Jump to

Keyboard shortcuts

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