Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicNotificationMessage ¶
BasicNotificationMessage 是一个泛型接口,Message 可以返回不同类型
type GeneratedMessage ¶ added in v0.1.5
type GeneratedMessage[T any] struct { Data T }
GeneratedMessage 兼容动态数据
func (*GeneratedMessage[T]) Message ¶ added in v0.1.5
func (m *GeneratedMessage[T]) Message() (T, error)
type Manager ¶ added in v0.1.19
type Manager struct {
// contains filtered or unexported fields
}
Manager 统一管理所有的通知 Handler
func NewManager ¶ added in v0.1.19
func NewManager() *Manager
type Message ¶ added in v0.1.19
type Message struct {
// 基础字段
To []string // 接收者列表 (UserID, Phone, Email 等,取决于 Channel)
Subject string // 标题 (邮件、飞书富文本等使用)
Content string // 内容 (文本内容)
Type MessageType // 消息类型
// 扩展字段
TemplateID string // 模版 ID (如短信、飞书模板消息)
TemplateVars map[string]any // 模版变量
Files []string // 附件链接
Extra map[string]any // 渠道特定的额外参数 (如飞书的 card_id, 交互配置等)
}
Message 是业务层使用的统一消息模型 它屏蔽了底层渠道的差异,提供了最常用的字段
type MessageType ¶ added in v0.1.19
type MessageType string
MessageType 定义消息类型
const ( MsgTypeText MessageType = "text" MsgTypeMarkdown MessageType = "markdown" // 部分渠道支持,不支持的可能降级为 Text MsgTypeCard MessageType = "card" // 复杂卡片,通常需要 channel 特定的 Extra 数据 )
type Notifier ¶
type Notifier[T any] interface { Send(ctx context.Context, message BasicNotificationMessage[T]) (bool, error) }
Notifier 是一个发送通知的接口,T 是 BasicNotificationMessage 的返回类型
type NotifierWrap ¶ added in v0.1.3
func WrapNotifierDynamic ¶ added in v0.1.5
func WrapNotifierDynamic[T any](notifier Notifier[T], messageGen func() ( BasicNotificationMessage[T], error)) NotifierWrap
func WrapNotifierStatic ¶ added in v0.1.5
func WrapNotifierStatic[T any](notifier Notifier[T], message BasicNotificationMessage[T]) NotifierWrap
WrapNotifierStatic 方法,支持静态和动态消息生成
type NotifierWrapper ¶ added in v0.1.3
type NotifierWrapper[T any] struct { Notifier Notifier[T] Message BasicNotificationMessage[T] MessageGen func() (BasicNotificationMessage[T], error) }
type SystemNotify ¶ added in v0.1.3
type SystemNotify struct {
Notify []NotifierWrap
}
func NewSystemNotify ¶ added in v0.1.3
func NewSystemNotify() *SystemNotify
func (*SystemNotify) AddNotify ¶ added in v0.1.3
func (n *SystemNotify) AddNotify(notifier NotifierWrap)
Click to show internal directories.
Click to hide internal directories.