broker

package
v1.21.24 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context)

Types

type Client

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

func Get

func Get() *Client

func New

func New(ctx context.Context) *Client

func (*Client) Publish

func (c *Client) Publish(topic string, data any)

func (*Client) Subscribe

func (c *Client) Subscribe(topic string, h OnDataFunc) Unsubscribe

type MessageItem

type MessageItem struct {
	Message any
	Topic   string
}

type OnDataFunc

type OnDataFunc func(MessageItem)

type Router

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

Router 支持对同一topic的多个订阅

func (*Router) Add

func (r *Router) Add(id string, topic string, f OnDataFunc) Unsubscribe

func (*Router) Group

func (r *Router) Group(topic string) map[string]OnDataFunc

func (*Router) Remove

func (r *Router) Remove(topic, id string)

type Unsubscribe

type Unsubscribe func()

Unsubscribe 取消订阅, 支持对同一topic的多个订阅

Jump to

Keyboard shortcuts

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