messagequeue

package
v0.3.0-20260911055116-... Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MetadataKeyQueueName = "queue_name"

MetadataKeyQueueName carries the queue name independently of the transport partition key. Producers set it on Message.Metadata so consumers can attribute work before decoding the payload.

Variables

This section is empty.

Functions

func QueueName

func QueueName(ctx context.Context) (string, bool)

QueueName returns the delivered message's queue name from ctx.

func ValidatePayloadQueue

func ValidatePayloadQueue(message Message, payloadQueue string) error

ValidatePayloadQueue verifies that a queue-bearing payload belongs to the persisted message tenant.

func ValidateTenantMetadata

func ValidateTenantMetadata(message Message) error

ValidateTenantMetadata verifies that the persisted shard identity agrees with queue metadata when metadata is present.

func WithQueueName

func WithQueueName(ctx context.Context, queueName string) context.Context

WithQueueName returns a child context containing the queue name of the delivered message.

Types

type Message

type Message struct {
	// ID uniquely identifies the message for deduplication and tracing.
	//
	// Deduplication is against every message the backend still holds for the
	// same topic and partition key — including ones already consumed, which are
	// reclaimed lazily and may outlive their delivery by an unbounded interval.
	// A publish whose ID collides is reported as a success and stores nothing.
	//
	// So the ID names the occasion to publish, not the entity published about.
	// Reusing an entity's own ID gives that entity one message for as long as
	// the backend remembers the first, and silently discards every later one.
	// Producers build IDs with platform/publish.IntentID rather than choosing
	// them by hand.
	ID string

	// Payload is the message body as raw bytes.
	Payload []byte

	// Metadata contains key-value pairs for headers and attributes.
	// Use for trace IDs, request IDs, and cross-service metadata.
	Metadata map[string]string

	// PartitionKey determines the ordering partition within Tenant.
	// Messages with the same Tenant and PartitionKey are delivered in order.
	// Optional - if empty, backend may use round-robin distribution.
	PartitionKey string

	// Tenant is the shard isolation identity persisted by the backend.
	// Domains map their queue name onto this field at publish time.
	Tenant string

	// PublishedAt is when the message was published (Unix milliseconds).
	PublishedAt int64
}

Message represents a queue message entity. Immutable - use Copy() for modifications.

func NewMessage

func NewMessage(id string, payload []byte, partitionKey string, metadata map[string]string) Message

NewMessage creates a new message with the given ID, payload, partition key, and metadata. If metadata is nil, it will be initialized as an empty map. PublishedAt is set to the current time.

func (Message) Copy

func (m Message) Copy() Message

Copy creates a deep copy of the message. Safe to call concurrently.

func (Message) PartitionIdentity

func (m Message) PartitionIdentity() PartitionIdentity

PartitionIdentity returns the message's tenant-scoped partition identity.

type PartitionIdentity

type PartitionIdentity struct {
	// Tenant is the shard isolation identity.
	Tenant string
	// PartitionKey is the partition key within the tenant.
	PartitionKey string
}

PartitionIdentity uniquely identifies a partition within a tenant. It is comparable and may be used as a map key.

Jump to

Keyboard shortcuts

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