queue

package
v0.0.0-...-2e42471 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name        string
	TenantID    string
	Size        int
	WorkerCount int
}

type ProcessFunc

type ProcessFunc[T any] func(ctx context.Context, data T)

type Queue

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

Queue represents a single tenant's queue.

func New

func New[T any](cfg Config, logger log.Logger, fn ProcessFunc[T]) *Queue[T]

func (*Queue[T]) Push

func (m *Queue[T]) Push(ctx context.Context, data T) error

Push pushes data onto a queue. If the queue is full, the data is dropped

func (*Queue[T]) ShouldUpdate

func (m *Queue[T]) ShouldUpdate(size, workerCount int) bool

ShouldUpdate returns true if the queue size or worker count (alive or total) has changed

func (*Queue[T]) Shutdown

func (m *Queue[T]) Shutdown(ctx context.Context) error

func (*Queue[T]) Size

func (m *Queue[T]) Size() int

Size returns the size of the queue.

func (*Queue[T]) StartWorkers

func (m *Queue[T]) StartWorkers()

func (*Queue[T]) TenantID

func (m *Queue[T]) TenantID() string

TenantID returns the tenant id.

func (*Queue[T]) WorkerCount

func (m *Queue[T]) WorkerCount() int

WorkerCount returns the number of expected workers.

Jump to

Keyboard shortcuts

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