Documentation ¶
Index ¶
- type Message
- type MessageBroker
- func (b *MessageBroker) Broadcast(msg Message)
- func (b *MessageBroker) Notify(bearerPredicate []byte, msg Message)
- func (b *MessageBroker) StreamSSE(ctx context.Context, owner PubKey, w http.ResponseWriter) error
- func (b *MessageBroker) Subscribe(pubkey PubKey) (<-chan Message, error)
- func (b *MessageBroker) Unsubscribe(pubkey PubKey, c <-chan Message)
- type PubKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageBroker ¶
type MessageBroker struct {
// contains filtered or unexported fields
}
func NewBroker ¶
func NewBroker(done <-chan struct{}) *MessageBroker
NewBroker constructs new MessageBroker (zero value is not usable).
When "done" chan is closed all in-flight event streams (StreamSSE calls) will be terminated.
func (*MessageBroker) Broadcast ¶
func (b *MessageBroker) Broadcast(msg Message)
func (*MessageBroker) Notify ¶
func (b *MessageBroker) Notify(bearerPredicate []byte, msg Message)
func (*MessageBroker) StreamSSE ¶
func (b *MessageBroker) StreamSSE(ctx context.Context, owner PubKey, w http.ResponseWriter) error
StreamSSE subscribes to broker with "owner" key and streams the messages it receives as server-sent events to "w" until "ctx" is cancelled or the "done" chan used as MessageBroker constructor parameter is closed (in both cases nil error is returned). Upon return it also unsubscribes from the message broker.
func (*MessageBroker) Subscribe ¶
func (b *MessageBroker) Subscribe(pubkey PubKey) (<-chan Message, error)
func (*MessageBroker) Unsubscribe ¶
func (b *MessageBroker) Unsubscribe(pubkey PubKey, c <-chan Message)
Click to show internal directories.
Click to hide internal directories.