Help us shape the future of Go! Take the 2026 Go Developer Survey

message

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Overview

Package message provides a protocol-neutral envelope and router.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilEnvelope   = errors.New("message: nil envelope")
	ErrTopicRequired = errors.New("message: topic is required")
)

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	Topic       string
	ID          string
	RequestID   string
	ExecutionID string
	TraceID     string
	SpanID      string
	Attempt     uint16
	Payload     any
}

Envelope carries delivery identity and an opaque payload. Publish does not copy it.

type Handler

type Handler func(context.Context, *Envelope) error

Handler receives the caller-owned envelope.

type Message

type Message = Envelope

Message is a domain-friendly alias for Envelope.

type Router

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

Router is a concurrent in-process router. Publish is allocation-free for a ready envelope.

func NewRouter

func NewRouter() *Router

func (*Router) Publish

func (r *Router) Publish(ctx context.Context, env *Envelope) error

func (*Router) Subscribe

func (r *Router) Subscribe(topic string, h Handler)

Jump to

Keyboard shortcuts

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