Documentation ¶
Index ¶
- type Broker
- func (b *Broker) Attach() (*Subscriber, error)
- func (b *Broker) Broadcast(payload interface{}, topics ...string)
- func (b *Broker) Detach(s *Subscriber)
- func (b *Broker) GetTopics() []string
- func (b *Broker) Subscribe(s *Subscriber, topics ...string)
- func (b *Broker) Subscribers(topic string) int
- func (b *Broker) Unsubscribe(s *Subscriber, topics ...string)
- type Message
- type Subscriber
- func (s *Subscriber) AddTopic(topic string)
- func (s *Subscriber) GetCreatedAt() int64
- func (s *Subscriber) GetID() string
- func (s *Subscriber) GetMessages() <-chan *Message
- func (s *Subscriber) GetTopics() []string
- func (s *Subscriber) RemoveTopic(topic string)
- func (s *Subscriber) Signal(m *Message) *Subscriber
- type Subscribers
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 The broker related meta data
func (*Broker) Attach ¶
func (b *Broker) Attach() (*Subscriber, error)
Attach Create a new subscriber and register it into our main broker
func (*Broker) Broadcast ¶
Broadcast broadcast the specified payload to all the topic(s) subscribers
func (*Broker) Detach ¶
func (b *Broker) Detach(s *Subscriber)
Detach remove the specified subscriber from the broker
func (*Broker) Subscribe ¶
func (b *Broker) Subscribe(s *Subscriber, topics ...string)
Subscribe subscribes the specified subscriber "s" to the specified list of topic(s)
func (*Broker) Subscribers ¶
Subscribers Get the subscribers count
func (*Broker) Unsubscribe ¶
func (b *Broker) Unsubscribe(s *Subscriber, topics ...string)
Unsubscribe Unsubscribe the specified subscriber from the specified topic(s)
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message The message metadata
func (*Message) GetCreatedAt ¶
GetCreatedAt Get the creation time of this message
func (*Message) GetPayload ¶
func (m *Message) GetPayload() interface{}
GetPayload Get the payload of the current message
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber ...
func NewSubscriber ¶
func NewSubscriber() (*Subscriber, error)
NewSubscriber returns a new subscriber
func (*Subscriber) AddTopic ¶
func (s *Subscriber) AddTopic(topic string)
AddTopic Adds a new topic to the subscriber
func (*Subscriber) GetCreatedAt ¶
func (s *Subscriber) GetCreatedAt() int64
GetCreatedAt return `time.Time` of the creation time
func (*Subscriber) GetMessages ¶
func (s *Subscriber) GetMessages() <-chan *Message
GetMessages returns a channel of *Message to listen on
func (*Subscriber) GetTopics ¶
func (s *Subscriber) GetTopics() []string
GetTopics return slice of subscriber topics
func (*Subscriber) RemoveTopic ¶
func (s *Subscriber) RemoveTopic(topic string)
RemoveTopic Removes a topic from the subscriber
func (*Subscriber) Signal ¶
func (s *Subscriber) Signal(m *Message) *Subscriber
Signal sends a message to subscriber