Documentation
¶
Index ¶
- Constants
- func CreateBatchSendNotificationTask(requests []*SendRequest, metadata map[string]interface{}) (*asynq.Task, error)
- func CreateRetryFailedNotificationTask(request *SendRequest, originalMessageID string, retryCount int, ...) (*asynq.Task, error)
- func CreateScheduledNotificationTask(request *SendRequest, scheduledAt time.Time, scheduleType string, ...) (*asynq.Task, error)
- func CreateSendNotificationTask(request *SendRequest, metadata map[string]interface{}) (*asynq.Task, error)
- func FormatPriority(priority int8) string
- func FormatPriorityIcon(priority int8) string
- func GetEventTypeIcon(eventType string) string
- func GetEventTypeText(eventType string) string
- func RenderTemplate(content string, request *SendRequest) (string, error)
- type Attachment
- type BaseChannelConfig
- type BatchSendNotificationPayload
- type ChannelConfig
- type EmailChannel
- func (e *EmailChannel) GetMaxRetries() int
- func (e *EmailChannel) GetName() string
- func (e *EmailChannel) GetRetryInterval() time.Duration
- func (e *EmailChannel) IsEnabled() bool
- func (e *EmailChannel) Send(ctx context.Context, request *SendRequest) (*SendResponse, error)
- func (e *EmailChannel) Validate() error
- type EmailConfig
- type FeishuChannel
- func (f *FeishuChannel) GetMaxRetries() int
- func (f *FeishuChannel) GetName() string
- func (f *FeishuChannel) GetRetryInterval() time.Duration
- func (f *FeishuChannel) IsEnabled() bool
- func (f *FeishuChannel) Send(ctx context.Context, request *SendRequest) (*SendResponse, error)
- func (f *FeishuChannel) Validate() error
- type FeishuConfig
- type Manager
- func (m *Manager) BatchSendNotification(ctx context.Context, requests []*SendRequest) ([]*SendResponse, error)
- func (m *Manager) Close() error
- func (m *Manager) GetAvailableChannels() []string
- func (m *Manager) GetChannelStats() map[string]interface{}
- func (m *Manager) ProcessNotificationTask(ctx context.Context, task *asynq.Task) error
- func (m *Manager) ReloadChannel(channelName string) error
- func (m *Manager) SendNotification(ctx context.Context, request *SendRequest) (*SendResponse, error)
- func (m *Manager) SendNotificationAsync(ctx context.Context, request *SendRequest, delay time.Duration) error
- func (m *Manager) ValidateChannelConfig(channelName string) error
- type NotificationChannel
- type NotificationConfig
- type Processor
- func (p *Processor) HandleBatchSendNotification(ctx context.Context, task *asynq.Task) error
- func (p *Processor) HandleRetryFailedNotification(ctx context.Context, task *asynq.Task) error
- func (p *Processor) HandleScheduledNotification(ctx context.Context, task *asynq.Task) error
- func (p *Processor) HandleSendNotification(ctx context.Context, task *asynq.Task) error
- func (p *Processor) RegisterTasks(mux *asynq.ServeMux)
- type RetryFailedNotificationPayload
- type ScheduledNotificationPayload
- type SendNotificationPayload
- type SendRequest
- type SendResponse
Constants ¶
View Source
const ( FeishuIDTypeOpenID = "open_id" FeishuIDTypeUserID = "user_id" FeishuIDTypeChatID = "chat_id" FeishuIDTypeEmail = "email" FeishuIDTypeUnionID = "union_id" )
飞书ID类型枚举
Variables ¶
This section is empty.
Functions ¶
func CreateBatchSendNotificationTask ¶
func CreateBatchSendNotificationTask(requests []*SendRequest, metadata map[string]interface{}) (*asynq.Task, error)
func CreateSendNotificationTask ¶
func CreateSendNotificationTask(request *SendRequest, metadata map[string]interface{}) (*asynq.Task, error)
func FormatPriorityIcon ¶
func GetEventTypeIcon ¶
func GetEventTypeText ¶
func RenderTemplate ¶
func RenderTemplate(content string, request *SendRequest) (string, error)
Types ¶
type Attachment ¶
type Attachment struct {
Name string `json:"name"` // 附件名称
Content []byte `json:"content"` // 附件内容
ContentType string `json:"content_type"` // 内容类型
Size int64 `json:"size"` // 大小
}
Attachment 附件
type BaseChannelConfig ¶
type BaseChannelConfig struct {
Enabled bool `json:"enabled" yaml:"enabled"` // 是否启用
MaxRetries int `json:"max_retries" yaml:"max_retries"` // 最大重试次数
RetryInterval time.Duration `json:"retry_interval" yaml:"retry_interval"` // 重试间隔
Timeout time.Duration `json:"timeout" yaml:"timeout"` // 超时时间
}
func (*BaseChannelConfig) GetMaxRetries ¶
func (c *BaseChannelConfig) GetMaxRetries() int
func (*BaseChannelConfig) GetRetryInterval ¶
func (c *BaseChannelConfig) GetRetryInterval() time.Duration
func (*BaseChannelConfig) GetTimeout ¶
func (c *BaseChannelConfig) GetTimeout() time.Duration
type BatchSendNotificationPayload ¶
type BatchSendNotificationPayload struct {
Requests []*SendRequest `json:"requests"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type ChannelConfig ¶
type EmailChannel ¶
type EmailChannel struct {
// contains filtered or unexported fields
}
func NewEmailChannel ¶
func NewEmailChannel(config EmailConfig, logger *zap.Logger) *EmailChannel
func (*EmailChannel) GetMaxRetries ¶
func (e *EmailChannel) GetMaxRetries() int
func (*EmailChannel) GetName ¶
func (e *EmailChannel) GetName() string
func (*EmailChannel) GetRetryInterval ¶
func (e *EmailChannel) GetRetryInterval() time.Duration
func (*EmailChannel) IsEnabled ¶
func (e *EmailChannel) IsEnabled() bool
func (*EmailChannel) Send ¶
func (e *EmailChannel) Send(ctx context.Context, request *SendRequest) (*SendResponse, error)
Send 发送邮件通知到指定收件人
func (*EmailChannel) Validate ¶
func (e *EmailChannel) Validate() error
type EmailConfig ¶
type FeishuChannel ¶
type FeishuChannel struct {
// contains filtered or unexported fields
}
func NewFeishuChannel ¶
func NewFeishuChannel(config FeishuConfig, logger *zap.Logger) *FeishuChannel
func (*FeishuChannel) GetMaxRetries ¶
func (f *FeishuChannel) GetMaxRetries() int
func (*FeishuChannel) GetName ¶
func (f *FeishuChannel) GetName() string
func (*FeishuChannel) GetRetryInterval ¶
func (f *FeishuChannel) GetRetryInterval() time.Duration
func (*FeishuChannel) IsEnabled ¶
func (f *FeishuChannel) IsEnabled() bool
func (*FeishuChannel) Send ¶
func (f *FeishuChannel) Send(ctx context.Context, request *SendRequest) (*SendResponse, error)
Send 发送飞书消息到指定接收人
func (*FeishuChannel) Validate ¶
func (f *FeishuChannel) Validate() error
type FeishuConfig ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) BatchSendNotification ¶
func (m *Manager) BatchSendNotification(ctx context.Context, requests []*SendRequest) ([]*SendResponse, error)
BatchSendNotification 批量发送通知
func (*Manager) GetAvailableChannels ¶
func (*Manager) GetChannelStats ¶
func (*Manager) ProcessNotificationTask ¶
func (*Manager) ReloadChannel ¶
func (*Manager) SendNotification ¶
func (m *Manager) SendNotification(ctx context.Context, request *SendRequest) (*SendResponse, error)
SendNotification 同步发送通知消息
func (*Manager) SendNotificationAsync ¶
func (m *Manager) SendNotificationAsync(ctx context.Context, request *SendRequest, delay time.Duration) error
SendNotificationAsync 异步发送通知消息
func (*Manager) ValidateChannelConfig ¶
type NotificationChannel ¶
type NotificationChannel interface {
GetName() string
// Send 发送通知
Send(ctx context.Context, request *SendRequest) (*SendResponse, error)
Validate() error
// IsEnabled 是否启用
IsEnabled() bool
GetMaxRetries() int
GetRetryInterval() time.Duration
}
NotificationChannel 通知渠道接口
type NotificationConfig ¶
type NotificationConfig interface {
GetEmail() EmailConfig
GetFeishu() FeishuConfig
}
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
func (*Processor) HandleBatchSendNotification ¶
func (*Processor) HandleRetryFailedNotification ¶
func (*Processor) HandleScheduledNotification ¶
func (*Processor) HandleSendNotification ¶
func (*Processor) RegisterTasks ¶
type RetryFailedNotificationPayload ¶
type RetryFailedNotificationPayload struct {
Request *SendRequest `json:"request"`
OriginalMessageID string `json:"original_message_id"`
RetryCount int `json:"retry_count"`
LastError string `json:"last_error"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type ScheduledNotificationPayload ¶
type ScheduledNotificationPayload struct {
Request *SendRequest `json:"request"`
ScheduledAt time.Time `json:"scheduled_at"`
ScheduleType string `json:"schedule_type"` // once, daily, weekly, monthly
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type SendNotificationPayload ¶
type SendNotificationPayload struct {
Request *SendRequest `json:"request"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type SendRequest ¶
type SendRequest struct {
MessageID string `json:"message_id"` // 消息ID
Subject string `json:"subject"` // 主题
Content string `json:"content"` // 内容
Priority int8 `json:"priority"` // 优先级 1-高 2-中 3-低
RecipientType string `json:"recipient_type"` // 接收人类型
RecipientID string `json:"recipient_id"` // 接收人ID
RecipientAddr string `json:"recipient_addr"` // 接收人地址(邮箱/手机号等)
RecipientName string `json:"recipient_name"` // 接收人名称
// 工单相关
InstanceID *int `json:"instance_id,omitempty"` // 工单实例ID
EventType string `json:"event_type"` // 事件类型
Metadata map[string]interface{} `json:"metadata,omitempty"` // 元数据
Templates map[string]string `json:"templates,omitempty"` // 模板变量
Attachments []Attachment `json:"attachments,omitempty"` // 附件
}
type SendResponse ¶
type SendResponse struct {
Success bool `json:"success"` // 是否成功
MessageID string `json:"message_id"` // 消息ID
ExternalID string `json:"external_id"` // 外部系统消息ID
Status string `json:"status"` // 状态
ErrorMessage string `json:"error_message"` // 错误信息
Cost *float64 `json:"cost,omitempty"` // 发送成本
SendTime time.Time `json:"send_time"` // 发送时间
ResponseData map[string]interface{} `json:"response_data,omitempty"` // 响应数据
}
Click to show internal directories.
Click to hide internal directories.