multiqueue

package
v0.5.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrThreadNotExists = errors.New("multiQueue: thread not exists")
	ErrClosed          = errors.New("multiQueue: closed")
)

Functions

This section is empty.

Types

type HandleFunc

type HandleFunc[T any] func(msg T)

type MultiQueue

type MultiQueue[T Sizeable] interface {
	Add(ctx context.Context, threadId string, msg T) (err error)
	CloseThread(threadId string) (err error)
	ThreadIds() []string
	Close() (err error)
}

func New

func New[T Sizeable](h HandleFunc[T], updater sizeUpdater, msgType int, maxThreadSize int) MultiQueue[T]

type Queue

type Queue[T Sizeable] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T Sizeable](id string, size, msgType int, updater sizeUpdater, h QueueHandler[T]) *Queue[T]

func (*Queue[T]) Close

func (q *Queue[T]) Close() error

func (*Queue[T]) TryAdd

func (q *Queue[T]) TryAdd(msg T) error

func (*Queue[T]) WaitOne

func (q *Queue[T]) WaitOne(ctx context.Context) (T, error)

type QueueHandler

type QueueHandler[T Sizeable] func(id string, msg T, q *mb.MB[T]) error

type QueueProvider

type QueueProvider[T Sizeable] interface {
	GetQueue(id string) *Queue[T]
	RemoveQueue(id string) error
	Close() error
}

func NewQueueProvider

func NewQueueProvider[T Sizeable](size, msgType int, updater sizeUpdater, handler QueueHandler[T]) QueueProvider[T]

type Sizeable added in v0.5.0

type Sizeable interface {
	MsgSize() uint64
}

Jump to

Keyboard shortcuts

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