broker

package
v0.2.18 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package broker defines a generic interface for a message broker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Publisher
	Subscriber
}

Broker combines the Publisher and Subscriber interfaces.

type Message

type Message struct {
	// ID is a unique identifier for the message.
	ID string
	// Metadata contains message metadata.
	Metadata map[string]string
	// Payload is the message content.
	Payload []byte
}

Message is a generic message structure.

type Publisher

type Publisher interface {
	// Publish sends messages to a topic.
	Publish(ctx context.Context, topic string, messages ...*Message) error
	// Close terminates the publisher's connection.
	Close() error
}

Publisher defines the interface for publishing messages.

type Subscriber

type Subscriber interface {
	// Subscribe returns a channel of messages for a given topic.
	Subscribe(ctx context.Context, topic string) (<-chan *Message, error)
	// Close terminates the subscriber's connection.
	Close() error
}

Subscriber defines the interface for subscribing to messages.

Jump to

Keyboard shortcuts

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