Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DelayMessage ¶
type DelayMessage struct { ID string `json:"id"` // 消息唯一标识 Topic string `json:"topic"` // 消息主题 Payload json.RawMessage `json:"payload"` // 消息内容 Delay time.Duration `json:"delay"` // 延迟时间 Timestamp time.Time `json:"timestamp"` // 消息创建时间 }
DelayMessage 表示延迟队列中的消息
type DelayQueue ¶
type DelayQueue struct {
// contains filtered or unexported fields
}
DelayQueue 实现了基于Redis的延迟队列
func NewDelayQueue ¶
func NewDelayQueue(client *redis.Client) *DelayQueue
NewDelayQueue 创建一个新的延迟队列实例
func (*DelayQueue) Pop ¶
func (q *DelayQueue) Pop(ctx context.Context, topic string) (*DelayMessage, error)
Pop 从队列中获取到期的消息
func (*DelayQueue) Push ¶
func (q *DelayQueue) Push(ctx context.Context, msg *DelayMessage) error
Push 将消息推送到延迟队列
Click to show internal directories.
Click to hide internal directories.