Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct { StreamMap map[string]observer.Property // contains filtered or unexported fields }
Broker holds maps of topics.
var ( // DefaultBrooker is a system wide Broker. To easily help developer use the event bus straight away. DefaultBrooker *Broker )
func NewBroker ¶
func NewBroker() *Broker
NewBroker creates new broker. If you don't need a specific broker, you can use the already created DefaultBroker
func (*Broker) GetPublisher ¶
GetPublisher will obtain a Publisher dedicated for this broker and topic
func (*Broker) GetSubscriber ¶
func (b *Broker) GetSubscriber(topic string, Handle func(i interface{}) error) *Subscriber
GetSubscriber will obtain Subscriber dedicated for this broker and topic with a handler function that will handle the message that it's received. In the Handle function, implementation MUST check for nil argument.
type Publisher ¶
Publisher is the publishing object. It automatically assigned with its broker and topic
type Subscriber ¶
type Subscriber struct { // Topic that subscribed. Topic string // Handle function that will be called if a message is published under this topic Handle func(i interface{}) error // Broker that this subscriber assigned to Broker *Broker // contains filtered or unexported fields }
Subscriber the subscriber of a broker. This subscriber already asigned with topic it should subscribe.
func (*Subscriber) Subscribe ¶
func (s *Subscriber) Subscribe()
Subscribe will attach this subscriber to its broker. Subscriber are not automaticaly attached when you get it from a broker. Until you call this function, this subscriber will not receive any message.
func (*Subscriber) Unsubscribe ¶
func (s *Subscriber) Unsubscribe()
Unsubscribe will detach this subscriber from its broker.