Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrSigInactive = errors.New("signaller inactive") ErrSigNoListener = errors.New("no signal listener") )
Error codes
Functions ¶
This section is empty.
Types ¶
type Listener ¶ added in v1.2.13
type Listener struct {
// contains filtered or unexported fields
}
Listener for signals managed by Signaller
type Signal ¶
type Signal interface{}
Signal can be any object (intrinsic or custom); it is the responsibility of the senders and receivers of signals to handle them accordingly.
type Signaller ¶
type Signaller struct {
// contains filtered or unexported fields
}
Signaller dispatches signals to multiple concurrent listeners. The sequence in which listeners are served is stochastic.
In highly concurrent environments with a lot of messages the sequence of signals seen by a listener can vary. This is due to the fact that a signal gets dispatched in a Go routine, so the next signal can be dispatched before a listener got the first one if the second Go routine handles the listener earlier. It is therefore mandatory that received signals from a listener get handled in a Go routine as well to keep latency low. If a listener violates that promise, it got removed from the list.
func (*Signaller) Drop ¶
Drop removes a listener from the list. Failing to drop or close a listener will result in hanging go routines.
func (*Signaller) Listener ¶ added in v1.2.13
Listener returns a new channel to listen on each time it is called. Function interested in listening should get the channel, start the for/select loop and drop the channel if the loop terminates. Requesting an listener and than not reading from it will block all other listeners of the signaller.
func (*Signaller) Retire ¶
func (s *Signaller) Retire()
Retire a signaller: This will terminate the dispatch loop for signals; no further send or listen operations are supported. A retired signaller cannot be re-activated.
func (*Signaller) SetLatency ¶ added in v1.2.13
SetLatency sets the max latency for listener. A listener is removed from the list if it violates this policy.