Documentation ¶
Overview ¶
Package events is the event notification subsystem of brig. It uses the backend's capabilities (in case of IPFS we use pubsub) to publish and subscribe to a topic of events. If an event was received it is forwarded to the caller side in order to react on it.
Index ¶
Constants ¶
const ( // UnknownEvent should not happen in practice. UnknownEvent = EventType(1 << iota) // FsEvent tells other remotes that our filesystem changed. FsEvent // NetEvent indicates to other peers that our network status changed. NetEvent )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventType ¶
type EventType int
EventType is the type of a
func EventFromString ¶
EventFromString tries to parse `ev` as event type. If it fails, an error will be returned.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener listens to incoming events from other remotes. For every event, a registered callback can be executed. It does not implement net.Listener and is only similar from a concept POV.
func NewListener ¶
NewListener constructs a new listener. `cfg` is used to read the event subsystem config. `bk` is a events.Backend. `ownAddr` is the addr of our own node.
func (*Listener) PublishEvent ¶
PublishEvent notifies other peers that something on our side changed. The "something" is defined by `ev`. PublishEvent does not block.
func (*Listener) RegisterEventHandler ¶
RegisterEventHandler remembers that `hdl` should be called whenever a event of type `ev` is being received. If `notifyOnOwn` is true, the handler will only be called for changes that came from our own node. If it is `false` it will only be called for
func (*Listener) SetupListeners ¶
SetupListeners sets up the listener to receive events from any of `addrs`. If `ctx` is being canceled, all listeners will stop. SetupListeners can be called several times, each time overwriting and stopping previous listeners.