pubsub

package
v19.0.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Publisher
	Subscriber
}

Backend combines all broker operations.

type Message

type Message struct {
	ID    string
	Event *event.CloudEvent
}

type Publisher

type Publisher interface {
	// Publish publishes one or more events.
	// Returns message IDs in the same order as input items.
	Publish(ctx context.Context, topic string, events ...*event.CloudEvent) ([]string, error)
}

type Subscriber

type Subscriber interface {
	// Subscribe reads events from a topic using a consumer group.
	// It first claims pending messages from dead consumers, then reads new messages.
	// If eventTypes is non-empty, only events matching these CloudEvent types are returned.
	//
	// Error handling: infrastructure errors (e.g., Redis connection failure, consumer group
	// creation failure) are terminal - the iterator stops after yielding the error.
	// Message-level errors (e.g., unmarshal failure, missing fields) are non-terminal - the
	// error is yielded but the iterator continues to the next message.
	Subscribe(ctx context.Context, topic, consumerGroup, consumerName string, eventTypes []string) iter.Seq2[Message, error]
	Ack(ctx context.Context, topic, consumerGroup string, messageIDs ...string) error
	// DeleteConsumer removes a consumer from a consumer group.
	// Should be called when a subscriber is done to avoid accumulating
	// stale consumer entries in Redis.
	DeleteConsumer(ctx context.Context, topic, consumerGroup, consumerName string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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