Documentation ¶
Overview ¶
Package hub describes event hubs that allow providers to broadcast events and allow consumers to receive them
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntityHub ¶
type EntityHub struct {
// contains filtered or unexported fields
}
EntityHub is responsible for broadcasting Entity events to subscribers Example usage:
entityHub := hub.NewEntityHub(20) go func() { sub, id := entityHub.Subscribe() defer entityHub.Unsubscribe(id) for { select { case payload := <-sub: fmt.Printf("%#v\n", payload) } } } entityHub.Broadcast(models.EntityEvent{StreamID: 1})
Expected output:
models.EntityEvent{StreamID:1, EntityID:0, Type:models.EntityEventType(nil)}
func NewEntityHub ¶
NewEntityHub creates a new hub for broadcasting Entity events to subscribers
func (*EntityHub) Broadcast ¶
func (h *EntityHub) Broadcast(payload models.EntityEvent)
Broadcast sends the message to all subscribers of this hub
func (*EntityHub) Subscribe ¶
func (h *EntityHub) Subscribe() (chan *models.EntityEvent, uint64)
Subscribe adds a new hub subscriber
func (*EntityHub) Unsubscribe ¶
Unsubscribe removes a hub subscriber
type StreamHub ¶
type StreamHub struct {
// contains filtered or unexported fields
}
StreamHub is responsible for broadcasting Stream events to subscribers Example usage:
streamHub := hub.NewStreamHub(20) go func() { sub, id := streamHub.Subscribe() defer streamHub.Unsubscribe(id) for { select { case payload := <-sub: fmt.Printf("%#v\n", payload) } } } streamHub.Broadcast(models.StreamEvent{StreamID: 1})
Expected output:
models.StreamEvent{StreamID:1, Type:models.StreamEventType(nil)}
func NewStreamHub ¶
NewStreamHub creates a new hub for broadcasting Stream events to subscribers
func (*StreamHub) Broadcast ¶
func (h *StreamHub) Broadcast(payload models.StreamEvent)
Broadcast sends the message to all subscribers of this hub
func (*StreamHub) Subscribe ¶
func (h *StreamHub) Subscribe() (chan *models.StreamEvent, uint64)
Subscribe adds a new hub subscriber
func (*StreamHub) Unsubscribe ¶
Unsubscribe removes a hub subscriber