优化通道关闭流程,只靠 batch id 索引通道

This commit is contained in:
2025-12-05 18:31:30 +08:00
parent 4a2dcabf58
commit 5649a03c47
6 changed files with 37 additions and 53 deletions

View File

@@ -1,24 +1,11 @@
package events
import (
"encoding/json"
"log/slog"
"github.com/hibiken/asynq"
)
const RemoveChannel = "channel:remove"
type RemoveChannelData struct {
Batch string `json:"batch"`
IDs []int32 `json:"ids"`
}
func NewRemoveChannel(data RemoveChannelData) *asynq.Task {
bytes, err := json.Marshal(data)
if err != nil {
slog.Error("序列化删除通道任务失败", "error", err)
return nil
}
return asynq.NewTask(RemoveChannel, bytes)
func NewRemoveChannel(batch string) *asynq.Task {
return asynq.NewTask(RemoveChannel, []byte(batch))
}