messaging

package
v0.1.78 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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

type HandlerFunc func(message Message) error

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.

type MessageType

type MessageType int

MessageType represents the type of a message.

Jump to

Keyboard shortcuts

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