broadcastqueue

package
v2.5.2-rc.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

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 an 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.

func (*BroadcastQueue) Write

func (bq *BroadcastQueue) Write(msg []byte) (int, error)

Write implements io.Writer, and is a trivial wrapper around Push.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL