Documentation ¶
Overview ¶
The presence package implements an interface for observing liveness of arbitrary keys (agents, processes, etc) on top of MongoDB. The design works by periodically updating the database so that watchers can tell an arbitrary key is alive.
Index ¶
- Variables
- type Change
- type Pinger
- type Watcher
- func (w *Watcher) Alive(key string) (bool, error)
- func (w *Watcher) Dead() <-chan struct{}
- func (w *Watcher) Err() error
- func (w *Watcher) StartSync()
- func (w *Watcher) Stop() error
- func (w *Watcher) Sync()
- func (w *Watcher) Unwatch(key string, ch chan<- Change)
- func (w *Watcher) Watch(key string, ch chan<- Change)
- Bugs
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Debug specifies whether the package will log debug messages. TODO(rog) allow debug level setting in the log package.
Functions ¶
This section is empty.
Types ¶
type Pinger ¶
type Pinger struct {
// contains filtered or unexported fields
}
Pinger periodically reports that a specific key is alive, so that watchers interested on that fact can react appropriately.
func NewPinger ¶
func NewPinger(base *mgo.Collection, key string) *Pinger
NewPinger returns a new Pinger to report that key is alive. It starts reporting after Start is called.
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
A Watcher can watch any number of pinger keys for liveness changes.
func (*Watcher) Alive ¶
Alive returns whether the key is currently considered alive by w, or an error in case the watcher is dying.
func (*Watcher) Dead ¶
func (w *Watcher) Dead() <-chan struct{}
Dead returns a channel that is closed when the watcher has stopped.
func (*Watcher) Err ¶
Err returns the error with which the watcher stopped. It returns nil if the watcher stopped cleanly, tomb.ErrStillAlive if the watcher is still running properly, or the respective error if the watcher is terminating or has terminated with an error.
func (*Watcher) StartSync ¶
func (w *Watcher) StartSync()
StartSync forces the watcher to load new events from the database.
func (*Watcher) Sync ¶
func (w *Watcher) Sync()
Sync forces the watcher to load new events from the database and blocks until all events have been dispatched.
Notes ¶
Bugs ¶
The pings and beings collection currently grow without bound.