updateProgress-3.lua 640 B

123456789101112131415161718192021222324252627282930313233
  1. --[[
  2. Update job progress
  3. Input:
  4. KEYS[1] Job id key
  5. KEYS[2] event stream key
  6. KEYS[3] meta key
  7. ARGV[1] id
  8. ARGV[2] progress
  9. Output:
  10. 0 - OK
  11. -1 - Missing job.
  12. Event:
  13. progress(jobId, progress)
  14. ]]
  15. local rcall = redis.call
  16. -- Includes
  17. --- @include "includes/getOrSetMaxEvents"
  18. if rcall("EXISTS", KEYS[1]) == 1 then -- // Make sure job exists
  19. local maxEvents = getOrSetMaxEvents(KEYS[3])
  20. rcall("HSET", KEYS[1], "progress", ARGV[2])
  21. rcall("XADD", KEYS[2], "MAXLEN", "~", maxEvents, "*", "event", "progress",
  22. "jobId", ARGV[1], "data", ARGV[2]);
  23. return 0
  24. else
  25. return -1
  26. end