queue

package
v0.0.0-...-8472706 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeCompositionProcessing = "composition_processing"
)
View Source
const (
	TopicCompositionProcessing = "composition-processing"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMessage

type BaseMessage struct {
	Type string `json:"type"`
}

BaseMessage is the base structure for all queue messages

type CompositionProcessingMessage

type CompositionProcessingMessage struct {
	BaseMessage
	ArtID         string `json:"art_id"`
	CompositionID string `json:"composition_id"`
}

CompositionProcessingMessage is the message for composition processing

func NewCompositionProcessingMessage

func NewCompositionProcessingMessage(artID, compositionID string) *CompositionProcessingMessage

func (*CompositionProcessingMessage) FromJSON

func (m *CompositionProcessingMessage) FromJSON(data []byte) error

func (*CompositionProcessingMessage) ToJSON

func (m *CompositionProcessingMessage) ToJSON() ([]byte, error)

type Handler

type Handler func(ctx context.Context, body []byte) error

Handler processes one message. Return error to retry/NACK.

type PostgresOptions

type PostgresOptions struct {
	MaxAttempts       int
	PollInterval      time.Duration
	VisibilityTimeout time.Duration
	BaseBackoff       time.Duration
}

PostgresOptions tunes PostgresQueue. Zero values mean defaults.

type PostgresQueue

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

PostgresQueue implements Queue with FOR UPDATE SKIP LOCKED.

func NewPostgresQueue

func NewPostgresQueue(db *sql.DB, opts PostgresOptions) *PostgresQueue

NewPostgresQueue wraps an existing *sql.DB. It does not close the DB.

func (*PostgresQueue) Close

func (q *PostgresQueue) Close() error

Close cancels in-flight Subscribe loops. Does not close the *sql.DB.

func (*PostgresQueue) Publish

func (q *PostgresQueue) Publish(ctx context.Context, topic string, body []byte) error

Publish inserts a pending job.

func (*PostgresQueue) Subscribe

func (q *PostgresQueue) Subscribe(ctx context.Context, topic, consumer string, h Handler) error

Subscribe blocks, claiming jobs for topic with SKIP LOCKED until ctx or Close.

type Queue

type Queue interface {
	Publish(ctx context.Context, topic string, body []byte) error
	Subscribe(ctx context.Context, topic, consumer string, h Handler) error
	Close() error
}

Queue is the job bus. Default impl: Postgres SKIP LOCKED.

Jump to

Keyboard shortcuts

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