Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker is used to interact with the pubsub architecture
func (*Broker) AddSubscriber ¶
func (broker *Broker) AddSubscriber() *Subscriber
AddSubscriber adds a new subscriber to the subscriber pool and returns its reference
func (*Broker) Publish ¶
Publish publishes messages flagged with a given monitor to the pubsub architecture
func (*Broker) Subscribe ¶
func (broker *Broker) Subscribe(subscriber *Subscriber, monitor string)
Subscribe can add a monitor to a given subscriber
func (*Broker) Unsubscribe ¶
func (broker *Broker) Unsubscribe(subscriber *Subscriber, monitor string)
Unsubscribe removes a monitor from a given subscriber
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is used to model pubsub messages
func NewMessage ¶
NewMessage constructs a new message
func (*Message) GetMessageBody ¶
GetMessageBody returns the body of the message
func (*Message) GetMonitor ¶
GetMonitor gives back the name of the monitor the message was flagged with
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber can listen to different monitors on a broker. Its messages channel will be updated whenever a new message is published with the associated broker.
func (*Subscriber) Destruct ¶
func (subscriber *Subscriber) Destruct()
Destruct destructs a Subscriber
func (*Subscriber) GetMonitors ¶
func (subscriber *Subscriber) GetMonitors() []string
GetMonitors returns a slice of all monitors the Subscriber is subscribed to.
func (*Subscriber) Listen ¶
func (subscriber *Subscriber) Listen(listener Listener)
Listen listens for messages on the messages channel and calls a Listener function with the message as an argument.
type Subscribers ¶
type Subscribers map[string]*Subscriber