增加生产数据结构的定义
This commit is contained in:
@ -7,6 +7,17 @@
|
||||
// Date : 2022-07-06 17:55
|
||||
package delay
|
||||
|
||||
// ProduceData 生产的数据结构
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:56 2022/7/6
|
||||
type ProduceData struct {
|
||||
MsgID string `json:"msg_id"` // 消息ID
|
||||
Timestamp int64 `json:"timestamp"` // 消息生成时间: ms
|
||||
Data map[string]interface{} `json:"data"` // 传入的业务数据
|
||||
}
|
||||
|
||||
// Queue 队列数据
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/util"
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
@ -65,7 +66,11 @@ func (rp *redisProduce) Produce(ctx context.Context, data ...*Queue) error {
|
||||
//
|
||||
// Date : 18:22 2022/7/6
|
||||
func (rp *redisProduce) buildAddMember(queueData *Queue) *redis.Z {
|
||||
byteData, _ := json.Marshal(queueData)
|
||||
byteData, _ := json.Marshal(&ProduceData{
|
||||
MsgID: util.String.Md5(util.String.GenRandom("", 16)),
|
||||
Timestamp: time.Now().UnixNano() / 1e6,
|
||||
Data: queueData.Data,
|
||||
})
|
||||
return &redis.Z{
|
||||
Score: float64(time.Now().Unix() + queueData.DelayTime),
|
||||
Member: string(byteData),
|
||||
|
Reference in New Issue
Block a user