mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 15:13:30 +00:00
23 lines
428 B
Go
23 lines
428 B
Go
package services
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"pkg/utils"
|
|
|
|
"github.com/hibiken/asynq"
|
|
)
|
|
|
|
func SetFileRemoveTask(fileId string, expire time.Duration) error {
|
|
client := utils.GetQueueClient()
|
|
json, err := json.Marshal(map[string]any{
|
|
"file_id": fileId,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_, err = client.Enqueue(asynq.NewTask("file:remove", json), asynq.ProcessIn(time.Duration(expire)*time.Second))
|
|
return err
|
|
}
|