driver

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	common.Daemon

	// Subscribe registers a named subscriber for the given topic and returns
	// a channel that will receive messages published to matching topics.
	Subscribe(name string, topic string) (<-chan Message, error)

	// GetSubscribers returns the names of all subscribers matching the given topic,
	// including those subscribed to parent topics.
	GetSubscribers(topic string) []string

	// Unsubscribe removes a subscriber from receiving events for the given topic.
	// The subscriber's channel is closed.
	Unsubscribe(name string, topic string) error

	// Publish dispatches an event to local subscribers and handles
	// cross-instance delivery (e.g., via Redis).
	// The from parameter is the publisher's name, used to skip self-delivery.
	Publish(from string, topic string, kind string, payload any) error
}

Driver defines the interface for subscription storage and event delivery.

func NewKafka

func NewKafka(brokers []string, groupID string, log log.Logger) (Driver, error)

func NewMemory

func NewMemory(log log.Logger) Driver

func NewRedis

func NewRedis(client *redis.Client, log log.Logger) (Driver, error)

type Message

type Message struct {
	From    string
	Topic   string
	Kind    string
	Payload any
}

Message represents an event delivered through a subscription channel.

Jump to

Keyboard shortcuts

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