getState-8.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --[[
  2. Get a job state
  3. Input:
  4. KEYS[1] 'completed' key,
  5. KEYS[2] 'failed' key
  6. KEYS[3] 'delayed' key
  7. KEYS[4] 'active' key
  8. KEYS[5] 'wait' key
  9. KEYS[6] 'paused' key
  10. KEYS[7] 'waiting-children' key
  11. KEYS[8] 'prioritized' key
  12. ARGV[1] job id
  13. Output:
  14. 'completed'
  15. 'failed'
  16. 'delayed'
  17. 'active'
  18. 'prioritized'
  19. 'waiting'
  20. 'waiting-children'
  21. 'unknown'
  22. ]]
  23. local rcall = redis.call
  24. if rcall("ZSCORE", KEYS[1], ARGV[1]) then
  25. return "completed"
  26. end
  27. if rcall("ZSCORE", KEYS[2], ARGV[1]) then
  28. return "failed"
  29. end
  30. if rcall("ZSCORE", KEYS[3], ARGV[1]) then
  31. return "delayed"
  32. end
  33. if rcall("ZSCORE", KEYS[8], ARGV[1]) then
  34. return "prioritized"
  35. end
  36. -- Includes
  37. --- @include "includes/checkItemInList"
  38. local active_items = rcall("LRANGE", KEYS[4] , 0, -1)
  39. if checkItemInList(active_items, ARGV[1]) ~= nil then
  40. return "active"
  41. end
  42. local wait_items = rcall("LRANGE", KEYS[5] , 0, -1)
  43. if checkItemInList(wait_items, ARGV[1]) ~= nil then
  44. return "waiting"
  45. end
  46. local paused_items = rcall("LRANGE", KEYS[6] , 0, -1)
  47. if checkItemInList(paused_items, ARGV[1]) ~= nil then
  48. return "waiting"
  49. end
  50. if rcall("ZSCORE", KEYS[7], ARGV[1]) then
  51. return "waiting-children"
  52. end
  53. return "unknown"