Documentation
¶
Overview ¶
Package sendqueue provides an async message send queue with rate limiting.
Usage:
pm.Register(sendqueue.New(sendqueue.Config{Rate: 5, Burst: 10})) // In a Handler: sqSvc := ctx.Service[*sendqueue.Plugin]("sendqueue") sq.Enqueue("chat_id", platform.TextMessage("hello"), nil)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Rate 全局消息发送速率(条/秒)
Rate float64
// Burst 令牌桶突发容量
Burst int
// PerTargetRate 单 target(群/用户)的速率(条/秒),0 表示不限
PerTargetRate float64
// PerTargetBurst 单 target 突发容量
PerTargetBurst int
// QueueSize 队列最大深度
QueueSize int
// Workers 消费 goroutine 数量
Workers int
// MaxRetries 发送失败最大重试次数
MaxRetries int
// RetryDelay 重试间隔
RetryDelay time.Duration
}
Config holds configuration for the send queue plugin.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin is the send queue plugin API.
func (*Plugin) Enqueue ¶
func (p *Plugin) Enqueue(chat platform.ChatInfo, msg platform.OutboundMessage, sender platform.Sender) error
Enqueue 将平台无关消息加入发送队列。
chat 指定目标会话(ID + IsGroup 路由信息),用于限流 key 和注入 ChatInfo。 若 sender 为 nil,使用 SetDefaultSender 设置的默认发送器。
func (*Plugin) SetDefaultSender ¶
SetDefaultSender sets the default platform-agnostic sender (recommended).
Click to show internal directories.
Click to hide internal directories.