pubsub

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CarrierRedis    = "redis"    // redis 载体
	CarrierKafka    = "kafka"    // kafka 载体
	CarrierRabbitMQ = "rabbitmq" // rabbitmq 载体
	CarrierRocketMQ = "rocketmq" // rocketmq 载体
	CarrierEtcd     = "etcd"     // etcd 载体
)
View Source
const (
	ErrExit = "exit" // 系统退出
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cbfunc

type Cbfunc struct {
	CbString func(msg string)
	CbByte   func(msg []byte)
	CbAny    func(msg any)
}

Cbfunc 回调函数

type Handler

type Handler interface {
	Subscribe(param Params, cbs *Cbfunc) // 订阅消息
	Publish(param Params, msg any) error // 发布消息
}

Handler 订阅发布组件

type Options

type Options struct {
	Ctx   context.Context
	Loger *zaploger.Logger
}

Options 配置

type Params

type Params struct {
	Topic string // 订阅主题
	Key   string // 订阅的key 主要在kafka的时候可以用这个
}

Params 参数

func (Params) String

func (this Params) String(isPath bool) string

String 返回字符串

type PubSub

type PubSub struct {
	Handler Handler
}

func Init

func Init(sb Handler) *PubSub

Init 初始化订阅发布组件

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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