bridge

package
v1.0.0-feature-modules... Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchAny

func MatchAny(patterns []string, topic string) bool

MatchAny delegates to protocol.MatchAny.

func MatchTopic

func MatchTopic(pattern, topic string) bool

MatchTopic delegates to protocol.MatchTopic.

Types

type EventBridge

type EventBridge struct {
	// contains filtered or unexported fields
}

EventBridge subscribes to the event.Bus and fans out matching events to connected WebSocket clients.

func NewEventBridge

func NewEventBridge(bus event.Bus, manager *connections.Manager, subs *store.Subscriptions, allowedPatterns []string) *EventBridge

NewEventBridge creates a new EventBridge.

func (*EventBridge) Start

func (b *EventBridge) Start(ctx context.Context) error

Start subscribes to all allowed event patterns on the event bus. For each incoming event, it fans out to all WebSocket clients subscribed to a matching topic.

func (*EventBridge) SubscribeTopic

func (b *EventBridge) SubscribeTopic(topic string) error

SubscribeTopic dynamically subscribes to an exact topic on the event bus so that events published by other modules are forwarded to WebSocket clients. Wildcard topics (containing * or **) are silently skipped because Watermill requires exact topic names — glob matching is handled at the WebSocket subscription store level. If allowedPatterns is configured, the topic must match at least one pattern.

type MessageHandler

type MessageHandler func(ctx context.Context, connID string, msg *protocol.Message) error

MessageHandler processes an incoming client message for a specific type.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router dispatches incoming client messages to registered handlers by type.

func NewRouter

func NewRouter() *Router

NewRouter creates a new Router.

func (*Router) Dispatch

func (r *Router) Dispatch(ctx context.Context, connID string, msg *protocol.Message) bool

Dispatch routes a parsed message to the registered handler. Returns false if no handler is registered for the message type.

func (*Router) Register

func (r *Router) Register(msgType protocol.MessageType, handler MessageHandler)

Register adds a handler for a message type.

Jump to

Keyboard shortcuts

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