Documentation
¶
Index ¶
Constants ¶
const ( MessageTypeLocal = iota MessageTypeRemote )
Variables ¶
This section is empty.
Functions ¶
func NewCombinedDispatcher ¶ added in v0.1.77
func NewCombinedDispatcher(dispatchers ...Dispatcher) *combinedDispatcher
Types ¶
type Dispatcher ¶
type Dispatcher interface {
Error() error
Publish(topic string, message Message)
Subscribe(topic string, fn HandlerFunc)
}
Dispatcher manages the communication between services.
func NewKafkaDispatcher ¶ added in v0.1.77
func NewKafkaDispatcher(ctx context.Context) Dispatcher
NewKafkaDispatcher creates a new instance of kafkaDispatcher.
func NewLocalDispatcher ¶ added in v0.1.77
func NewLocalDispatcher() Dispatcher
NewLocalDispatcher creates a new instance of locallocalDispatcher.
type HandlerFunc ¶
HandlerFunc is a function that handles a message and returns nil if the message was handled successfully or an error if there was an issue handling the message.
type Message ¶
type Message struct {
Data []byte
Type MessageType
}
Message represents a message that can be sent or received. It contains the data and type of the message which can be internal or external.
Internal messages are used for communication within the same service. External messages are used for communication between different services.
func NewMessage ¶
func NewMessage(data []byte, messageType MessageType) Message
NewMessage creates a new message with the given data and type.