queue

package
v0.0.0-...-40039a6 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: GPL-3.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 Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue is a message queue with multiple channels, where every message is broadcast to all subscribers of a channel It will automatically close the channels for and remove subscribers whose context has ended, or buffer is full

func New

func New(ctx context.Context, bufferSize int) *Queue

New creates a new queue

func (*Queue) CreateChannel

func (q *Queue) CreateChannel(channelName string) (chan<- []byte, error)

CreateChannel creates a new queue channel and returns a channel for broadcasting to it

func (*Queue) Subscribe

func (q *Queue) Subscribe(context context.Context, channelName string) (<-chan []byte, error)

Subscribe subscribes to a queue channel, and returns a channel for receiving messages Consumers should check whether the channel is closed, as the queue may terminate subscriptions at any time Returns an error if the given channel doesn't exist

func (*Queue) SubscriberCount

func (q *Queue) SubscriberCount() (subscriberCount int)

SubscriberCount returns the total count of subscribers for all channels

Jump to

Keyboard shortcuts

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