Help us shape the future of Go! Take the 2026 Go Developer Survey

bus

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish

func Publish(ev *Event)

Publish 发布事件

func Subscribe

func Subscribe(topic string, queue string, h Handler) error

Subscribe 订阅事件

func SubscribeWithExpire

func SubscribeWithExpire(topic string, queue string, expire time.Duration, h Handler) error

func Unsubscribe

func Unsubscribe(topic string, queue string)

Unsubscribe 取消订阅

Types

type Event

type Event struct {
	Flag    string      `json:"flag,omitempty"`
	Topic   string      `json:"topic,omitempty"`
	Message interface{} `json:"message,omitempty"`
	Params  interface{} `json:"params,omitempty"`
	Queue   string      `json:"queue,omitempty"`
	// contains filtered or unexported fields
}

Event is given to a subscription handler for processing

func NewEvent

func NewEvent(flag string, topic string, data interface{}, params interface{}) *Event

type Handler

type Handler func(*Event) error

Handler is used to process messages via a subscription of a topic. The handler is passed a publication interface which contains the message and optional Ack method to acknowledge receipt of the message.

type Subscriber

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

Subscriber 订阅者

Jump to

Keyboard shortcuts

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