bus

package
v2.0.84 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 2 Imported by: 9

README

事件总线

支持:

  • kafka
  • nats

Documentation

Index

Constants

View Source
const (
	APP_NAME = "bus"
)
View Source
const (
	APP_PRIORITY = 595
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Subject string
	Header  map[string][]string
	Data    []byte
}

type EventHandler

type EventHandler func(*Event)

type Publisher

type Publisher interface {
	// 事件发送
	Publish(ctx context.Context, e *Event) error
}

type Service

type Service interface {
	Publisher
	SubScriber
}

func GetService

func GetService() Service

type SubScriber

type SubScriber interface {
	// 主题订阅, 应用的多个实例 都会收到一份消息(广播)
	TopicSubscribe(ctx context.Context, subject string, cb EventHandler) error
	// 队列订阅, 默认应用名称为队列名称, 同一个队列中 只能收到一份消息
	QueueSubscribe(ctx context.Context, subject string, cb EventHandler) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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