Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastQueue ¶
type BroadcastQueue struct {
// contains filtered or unexported fields
}
BroadcastQueue represents a set of infinitely buffering queues. The zero value is valid and may be used.
func (*BroadcastQueue) Close ¶
func (bq *BroadcastQueue) Close()
Close marks each subscriber queue as "finished", all subscriber queues will be closed and further pushes are forbidden.
After .Close() is called:
- any calls to .Push() wil panic
- any calls to .Subscribe() will return an already-closed channel.
- any existing subscriber queue channels will be closed once they have been drained of messages that have already been Pushed.
func (*BroadcastQueue) Push ¶
func (bq *BroadcastQueue) Push(msg string)
Push pushes a value to each of the subscriber queues. Push does not block. It is a runtime error (panic) to call Push on a BroadcastQueue that has already had Close called on it.
func (*BroadcastQueue) Subscribe ¶
func (bq *BroadcastQueue) Subscribe(ctx context.Context) <-chan string
Subscribe allocates a new queue that future calls to Push will be broadcast to. The queue is removed from the pool that is broadcast to when the Context is canceled. Reading from the returned channel will pop from the queue. The channel will be closed when either the Context is canceled or the BroadcastQueue is closed.