1// Package message provides a simple message broker implementation.2package message34// TopicAll defines a topic for all types of message.5// This topic can be used to subscribe to message for all topics.6const TopicAll Topic = "*"78type (9 // Topic defines a type for message topics.10 Topic string1112 // Callback defines a type for message callbacks.13 Callback func(Message)1415 // Message defines a type for published messages.16 Message struct {17 // Topic is the message topic.18 Topic Topic1920 // Data contains optional message data.21 Data any22 }2324 // Publisher defines an interface for message publishers.25 Publisher interface {26 // Publish publishes a message for a topic.27 Publish(_ Topic, data any) error28 }2930 // Subscriber defines an interface for message subscribers.31 Subscriber interface {32 // Subscribe subscribes to messages published for a topic.33 // It returns the callback ID within the topic.34 Subscribe(Topic, Callback) (id int, _ error)3536 // Unsubscribe unsubscribes a callback from a message topic.37 // ID is the callback ID within the topic, returned on subscription.38 Unsubscribe(_ Topic, id int) (unsubscribed bool, _ error)39 }40)41Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.