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

module

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyHealthCheckFunction = func(ctx context.Context) (err error) { return nil }
)

Functions

func Get

func Get[T Module](kind ModuleKind) []T

func NewDelayEventModule

func NewDelayEventModule(moduleObject any, app string, functions map[string]DelayEventFunction, options ...DelayEventModuleOption) error

NewDelayEventModule 初始化延迟消息模块

func NewEventModule

func NewEventModule(moduleObject any, app, pubsub string, functions map[string]EventFunction, options ...EventModuleOption) error

NewEventModule 新建事件模块会执行下列操作:

func NewHealthModule

func NewHealthModule(moduleObject any, app string, fn HealthCheckFunction) error

NewHealthModule 注册健康模块

func NewInvocationModule

func NewInvocationModule(moduleObject any, app string, alias2handler map[string]InvocationFunction) error

Types

type DelayEventFunction

type DelayEventFunction func(message []byte) (retry bool, err error)

type DelayEventHandler

type DelayEventHandler interface {
	GetTopic() string
	Handle(ctx context.Context, logger types.LoggerProvider, msgChan <-chan *types.Message)
}

type DelayEventModule

type DelayEventModule interface {
	Module
	RegisterHandlers(functions map[string]DelayEventFunction) error // 注册Handlers
	GetHandlers() []DelayEventHandler                               // 获取handlers
	GetAckTimeout() time.Duration
	GetBackOffPolicy() backoff.BackOff
}

type DelayEventModuleOption

type DelayEventModuleOption func(*delayEventModuleImpl)

func WithBackOff

func WithBackOff(backoff backoff.BackOff) DelayEventModuleOption

type EventFunction

type EventFunction func(ctx biz.Context, data []byte) (retry bool, err error)

type EventModule

type EventModule interface {
	Module
	RegisterHandlers(functions map[string]EventFunction) error // 注册Handlers
	GetHandlers() []eventHandler                               // 获取handlers
	GetPubSub() string
	GetAckTimeout() time.Duration
}

type EventModuleOption

type EventModuleOption func(*eventModuleImpl)

func WithConsumerTimeout

func WithConsumerTimeout(duration time.Duration) EventModuleOption

type HandlerMatcher

type HandlerMatcher func(methodName string) (string, bool) // 传入receiver.methodName, 判断是否匹配,然后取出处理后的handlerName

type HealthCheckFunction

type HealthCheckFunction func(context.Context) error

type HealthModule

type HealthModule interface {
	Module
	GetHandler() common.HealthCheckHandler
}

type Info

type Info struct {
	ApiVersion int    // API版本
	Name       string // 规范化的模块名
	Dir        string // 模块所在目录
}

func ParseModuleInfo

func ParseModuleInfo(pkgPath, moduleName string) (*Info, error)

ParseModuleInfo 合法的包路径可能为以下格式: * /path/to/v1 * /path/to/v1/pc * /path/to/v2/wxmp

type InvocationFunction

type InvocationFunction func(ctx biz.Context, data []byte) (any, error)

type InvocationModule

type InvocationModule interface {
	Module
	RegisterHandlers(functions map[string]InvocationFunction) error // 注册Handlers
	GetHandlers() []invocationHandler                               // 获取handlers
}

type Module

type Module interface {
	GetApp() string
	GetInfo() *Info
	GetKind() ModuleKind
}

type ModuleKind

type ModuleKind int
const (
	ModuleKindUnknown    ModuleKind = iota
	ModuleKindInvocation            // service invocation module
	ModuleKindEvent                 // topic event module
	ModuleKindDelayEvent            // delay event module
	ModuleKindHealth                // health module
)

Jump to

Keyboard shortcuts

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