You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

task.go 687 B

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334
  1. package worker
  2. import (
  3. "context"
  4. "code.gitea.io/gitea/modules/log"
  5. "github.com/RichardKnop/machinery/v1/tasks"
  6. )
  7. // 方法名
  8. const (
  9. DecompressTaskName = "Decompress"
  10. )
  11. func SendDecompressTask(ctx context.Context, uuid string) error {
  12. args := []tasks.Arg{{Name: "uuid", Type: "string", Value: uuid}}
  13. task, err := tasks.NewSignature(DecompressTaskName, args)
  14. if err != nil {
  15. log.Error("NewSignature failed:", err.Error())
  16. return err
  17. }
  18. task.RetryCount = 3
  19. _, err = AsyncTaskCenter.SendTaskWithContext(ctx, task)
  20. if err != nil {
  21. log.Error("SendTaskWithContext failed:", err.Error())
  22. return err
  23. }
  24. log.Info("SendDecompressTask(%s) success", uuid)
  25. return nil
  26. }