2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-12-26 07:42:17 +08:00

fix empty id

This commit is contained in:
cn-kali-team 2023-01-06 18:23:40 +08:00
parent cc777ebdaa
commit cac7636bbc

View File

@ -661,6 +661,7 @@ for _, id in ipairs(ids) do
local msg, result = unpack(redis.call("HMGET", key, "msg","result")) local msg, result = unpack(redis.call("HMGET", key, "msg","result"))
table.insert(data, msg) table.insert(data, msg)
table.insert(data, result) table.insert(data, result)
table.insert(data, id)
end end
return data return data
`) `)
@ -690,7 +691,7 @@ func (r *RDB) listMessages(qname string, state base.TaskState, pgn Pagination) (
return nil, errors.E(errors.Internal, fmt.Errorf("cast error: Lua script returned unexpected value: %v", res)) return nil, errors.E(errors.Internal, fmt.Errorf("cast error: Lua script returned unexpected value: %v", res))
} }
var infos []*base.TaskInfo var infos []*base.TaskInfo
for i := 0; i < len(data); i += 2 { for i := 0; i < len(data); i += 3 {
m, err := base.DecodeMessage([]byte(data[i])) m, err := base.DecodeMessage([]byte(data[i]))
if err != nil { if err != nil {
continue // bad data, ignore and continue continue // bad data, ignore and continue
@ -703,6 +704,9 @@ func (r *RDB) listMessages(qname string, state base.TaskState, pgn Pagination) (
if state == base.TaskStatePending { if state == base.TaskStatePending {
nextProcessAt = r.clock.Now() nextProcessAt = r.clock.Now()
} }
if m.ID == "" {
m.ID = data[i+2]
}
infos = append(infos, &base.TaskInfo{ infos = append(infos, &base.TaskInfo{
Message: m, Message: m,
State: state, State: state,