bus

package
v2.0.68 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 2 Imported by: 9

README

事件总线

支持:

  • kafka
  • nats

Documentation

Index

Constants

View Source
const (
	APP_NAME = "bus"
)

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 {
	// 订阅事件
	Subscribe(ctx context.Context, subject string, cb EventHandler) error
	// 订阅队列
	// subject: 主题
	// queue: 队列名称, kafka则为消费组名称
	Queue(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