Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEventBus ¶
NewEventBus 创建 RabbitMQ 事件总线
url 格式:amqp://username:password@host:port/vhost 例如:amqp://guest:guest@localhost:5672/
使用示例:
bus, err := rabbitmq.NewEventBus("amqp://guest:guest@localhost:5672/")
if err != nil {
log.Fatal(err)
}
defer bus.Close()
// 使用发布者
publisher := bus.Publisher()
publisher.Publish(ctx, "user.created", data)
// 使用订阅者
subscriber := bus.Subscriber()
subscriber.Subscribe("user.created", "email-service", handler)
func NewEventBusFromConfig ¶
NewEventBusFromConfig 从配置创建事件总线
func NewPublisher ¶
NewPublisher 创建 RabbitMQ 发布者
url 格式:amqp://username:password@host:port/vhost 例如:amqp://guest:guest@localhost:5672/
func NewSubscriber ¶
func NewSubscriber(url string) (messaging.Subscriber, error)
NewSubscriber 创建 RabbitMQ 订阅者
url 格式:amqp://username:password@host:port/vhost 例如:amqp://guest:guest@localhost:5672/
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.