queue

package module
v0.0.0-...-2d28c6b Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package queue provides ficilities for working with message queues.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStopped is returned when the queue is stopped.
	ErrStopped = errors.New("stopped")
	// ErrFull is returned when the queue is full.
	ErrFull = errors.New("full")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	ID        string
	Type      EventType
	EntityID  string
	Entity    any
	CreatedAt time.Time
}

Event is a common event design.

type EventType

type EventType string

type M

type M struct {
	ID            string
	ContentType   string
	ContentLength int // In bytes
	CreatedAt     time.Time
	Metadata      Metadata
	Body          []byte
}

M is a queue message.

type Metadata

type Metadata map[string]string

type Pub

type Pub[e any] interface {
	Pub(ctx context.Context, e Event) error
}

type PubSub

type PubSub[K comparable, E any] interface {
	Server
	Pub(context.Context, E) error
	Sub(context.Context, K) (Subscription[E], error)
}

PubSub is an interface for the Publish–Subscribe pattern.

type Server

type Server interface {
	Start(context.Context) error
	Stop(context.Context) error
}

Server is an interface for long-running.

type Subscription

type Subscription[E any] interface {
	Close() error
	Ch() <-chan E
}

Directories

Path Synopsis
Package redisq provides a Redis Stream based message queue.
Package redisq provides a Redis Stream based message queue.

Jump to

Keyboard shortcuts

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