Sha256: 362a8ce244355188775d7188e318d6b64f966283bc52b1919cf3d26ee347abb1

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

local function find_digest_in_process_set(digest)
  local process_cursor = 0
  local job_cursor     = 0
  local pattern        = "*" .. digest .. "*"
  local found          = false

  log_debug("Searching in process list",
            "for digest:", digest,
            "cursor:", process_cursor)

  repeat
    local process_paginator   = redis.call("SSCAN", "processes", process_cursor, "MATCH", "*")
    local next_process_cursor = process_paginator[1]
    local processes           = process_paginator[2]
    log_debug("Found number of processes:", #processes, "next cursor:", next_process_cursor)

    for _, process in ipairs(processes) do
      local workers_key = process .. ":workers"
      log_debug("searching in process set:", process,
                "for digest:", digest,
                "cursor:", process_cursor)

      local jobs = redis.call("HGETALL", workers_key)

      if #jobs == 0 then
        log_debug("No entries in:", workers_key)
      else
        for i = 1, #jobs, 2 do
          if string.find(jobs[i +1], digest) then
            log_debug("Found digest", digest, "in:", workers_key)
            found = true
            break
          end
        end
      end

      if found == true then
        break
      end
    end

    process_cursor = next_process_cursor
  until found == true or process_cursor == "0"

  return found
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.0.0.beta29 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
sidekiq-unique-jobs-7.0.0.beta28 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
sidekiq-unique-jobs-7.0.0.beta27 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
sidekiq-unique-jobs-7.0.0.beta26 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
sidekiq-unique-jobs-7.0.0.beta25 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
sidekiq-unique-jobs-7.0.0.beta24 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
sidekiq-unique-jobs-7.0.0.beta23 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua
sidekiq-unique-jobs-7.0.0.beta22 lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua