message

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package message defines the outbox data model.

Index

Constants

View Source
const TableName = "outbox_messages"

TableName is the fixed outbox table name. The schema is configurable at runtime; the table name itself is constant so it stays in lockstep with the embedded migration.

Variables

View Source
var (
	// ErrEmptyTopic is returned when a message has no topic.
	ErrEmptyTopic = errors.New("outbox: message topic is empty")
	// ErrNilPayload is returned when a message payload is nil.
	ErrNilPayload = errors.New("outbox: message payload is nil")
)

Functions

This section is empty.

Types

type Message

type Message struct {
	ID           string            // uuid; empty -> generated by the database
	Topic        string            // transport destination (queue/topic/subject)
	PartitionKey string            // ordering key (used by ordered mode)
	Payload      []byte            // opaque bytes; encoding is the codec's job
	Headers      map[string]string // transport metadata
	ContentType  string            // codec hint, e.g. "application/json"
	MessageType  string            // logical message type
	MaxAttempts  *int              // per-message override; nil -> relay default

	// Populated when read back by the relay.
	Status        Status
	Attempts      int
	LockedBy      string
	LockedUntil   *time.Time
	NextAttemptAt time.Time
	LastError     string
	CreatedAt     time.Time
	PublishedAt   *time.Time
}

Message is a single outbox row.

On enqueue, the caller sets Topic and Payload (required) and optionally ID, PartitionKey, Headers, ContentType, MessageType, MaxAttempts. The remaining fields are populated by the relay when a message is read back.

func (Message) Validate

func (m Message) Validate() error

Validate reports whether the message is well-formed for enqueue.

type Status

type Status string

Status is the lifecycle state of an outbox message.

const (
	StatusPending    Status = "pending"
	StatusProcessing Status = "processing"
	StatusPublished  Status = "published"
	StatusDead       Status = "dead"
)

Jump to

Keyboard shortcuts

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