broker

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package broker provides broker implementations for cross-node message delivery. Package broker 提供跨节点消息投递的 broker 实现,包含本地进程内和 RabbitMQ 两种。

Package broker — see local.go for the full package doc. 本文件实现基于 RabbitMQ 的 broker,支持自动重连和 topic exchange 路由。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Local

func Local(nodeID string) realtime.Broker

Local returns an in-process best-effort pub/sub broker. Local 返回进程内 broker,实现同进程 topic 分发,适合单节点或测试场景。

func RabbitMQ

func RabbitMQ(opts RabbitMQOptions) (realtime.Broker, error)

RabbitMQ creates a RabbitMQ-backed broker using a topic exchange. Delivery is best-effort and intended for online websocket fan-out: messages are transient, consumers auto-ack, and handler errors are logged but not retried. RabbitMQ 创建基于 topic exchange 的 broker,并在连接断开后按 ReconnectInterval 自动重连。

Types

type RabbitMQOptions

type RabbitMQOptions struct {
	// URL 是 RabbitMQ AMQP 连接地址。
	URL string
	// Exchange 是 topic exchange 名称。
	Exchange string
	// NodeID 标识当前 broker 节点,会写入 source_node header。
	NodeID string
	// QueuePrefix 是自动声明队列的名称前缀。
	QueuePrefix string
	// ReconnectInterval 是连接断开后的重试间隔。
	ReconnectInterval time.Duration
	// Logger 用于输出 handler 错误和重连状态。
	Logger realtime.LogSink
}

RabbitMQOptions configures a RabbitMQ-backed realtime.Broker. RabbitMQOptions 配置 RabbitMQ broker;空值会使用本地开发友好的默认值。

Jump to

Keyboard shortcuts

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