Documentation
¶
Index ¶
Constants ¶
const ( ErrNilSubChannel = Error("Uninitialised subscriber channel") ErrGeneratingKey = Error("Error generating key") )
ErrNilSubChannel represents an error occurring when a subscriber channel is uninitialized. ErrGeneratingKey represents an error that occurs while generating a key.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error string
Error represents a textual error value that implements the error interface.
type MessageHandler ¶
type MessageHandler[T any] chan TopicMessage[T]
MessageHandler is a channel used to handle incoming TopicMessage objects for a specific subscription. It allows processing messages in a concurrent manner.
type Publisher ¶
type Publisher[T any] interface { Publish(msg TopicMessage[T]) }
Publisher is an interface for publishing messages to a specified topic. It provides the `Publish` method, which accepts a `TopicMessage` for delivery. Typically used in messaging systems to distribute messages across subscribers.
type PublisherSubscriber ¶
type PublisherSubscriber[T any] interface { Publisher[T] Subscriber[T] Unsubscriber }
PublisherSubscriber is an interface that combines publishing, subscribing, and unsubscribing functionalities for a message-bus system.
func NewMessageBus ¶
func NewMessageBus[T any]() PublisherSubscriber[T]
NewMessageBus creates and initialises a new instance of a message bus implementing the PublisherSubscriber interface.
type Subscriber ¶
type Subscriber[T any] interface { Subscribe(topic Topic, handler MessageHandler[T]) (uuid.UUID, error) }
Subscriber defines behaviour for consuming messages from specific topics with unique handlers. The Subscribe method registers a handler for a topic and returns a unique identifier or an error.
type Topic ¶
type Topic string
Topic represents a category or channel for messages in a publish-subscribe system.
type TopicMessage ¶
TopicMessage represents a message linked to a specific topic within a pub/sub system or message bus. The Topic field defines the subject, and Message holds the message payload as a byte slice.
type Unsubscriber ¶
Unsubscriber defines an interface for removing a subscription from a specified topic using a unique identifier.