Skip to content

feat(queue): support getCountsPerPriority method [elixir] [dotnet] - #4535

Open
roggervalf wants to merge 12 commits into
masterfrom
getCountsPerPriority
Open

feat(queue): support getCountsPerPriority method [elixir] [dotnet]#4535
roggervalf wants to merge 12 commits into
masterfrom
getCountsPerPriority

Conversation

@roggervalf

@roggervalf roggervalf commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Port Impact Checklist

  • Python – does this change need to be ported or documented in the Python library?
  • Elixir – does this change need to be ported or documented in the Elixir library?
  • PHP – does this change need to be ported or documented in the PHP library?
  • Rust – does this change need to be ported or documented in the Rust library?
  • .NET – does this change need to be ported or documented in the .NET library?

Why

Enter your explanation here.

How

Enter the implementation details here.

Additional Notes (Optional)

Any extra info here.

Copilot AI lite review requested due to automatic review settings August 8, 2026 06:50
@roggervalf
roggervalf force-pushed the getCountsPerPriority branch from 4a84c32 to ba327aa Compare August 8, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Elixir support for getCountsPerPriority by introducing a new get_counts_per_priority/3 API and backing Redis script call, while also aligning multiple ports to the 2-key getCountsPerPriority-2.lua signature (wait + prioritized).

Changes:

  • Add Elixir Queue.get_counts_per_priority/3 + backend plumbing and tests.
  • Update getCountsPerPriority-2.lua (and callers across Node/Rust/Python/PHP) to pass only the required keys.
  • Update Rust/Python/PHP script registries/wrappers to reference the -2.lua script variant.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/commands/getCountsPerPriority-2.lua Adjust Lua script key contract to (wait, prioritized).
src/classes/redis-queue-backend.ts Update Node Redis backend args to pass only required keys.
rust/src/scripts.rs Register getCountsPerPriority as a 2-key script using getCountsPerPriority-2.lua.
rust/src/queue.rs Pass only wait + prioritized keys when invoking the script.
python/bullmq/scripts.py Build script args with only wait + prioritized keys.
python/bullmq/redis_connection.py Update script filename mapping to getCountsPerPriority-2.lua.
php/src/Scripts.php Pass only wait + prioritized keys and exec getCountsPerPriority-2.lua.
elixir/test/bullmq/queue_getters_test.exs Add coverage for get_counts_per_priority/3, including paused behavior and deduping.
elixir/lib/bullmq/scripts.ex Add Redis script wrapper get_counts_per_priority/3.
elixir/lib/bullmq/queue.ex Add public API get_counts_per_priority/3 and GenServer handler.
elixir/lib/bullmq/backends/redis.ex Implement backend callback for Redis backend.
elixir/lib/bullmq/backend.ex Add backend callback + dispatcher function for counts-per-priority.
Suppressed comments (2)

src/commands/getCountsPerPriority-2.lua:13

  • This script now treats KEYS[2] as the prioritized ZSET. Callers that still pass the legacy 4-key list (wait, paused, meta, prioritized) will end up with KEYS[2]=paused, and ZCOUNT will hit a list key (WRONGTYPE) or count the wrong structure. For example, the .NET RedisBackend still passes 4 keys. Consider making the script backward compatible by preferring KEYS[4] when present.
    src/commands/getCountsPerPriority-2.lua:6
  • The top-of-file comment still says "Get counts per provided states", but this script counts per priority values. Updating this header avoids misleading documentation for maintainers.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread elixir/lib/bullmq/backend.ex
Comment thread rust/src/scripts.rs
Comment on lines 254 to 259
("paginate", 1, include_str!("commands/paginate-1.lua")),
(
"getCountsPerPriority",
4,
include_str!("commands/getCountsPerPriority-4.lua"),
2,
include_str!("commands/getCountsPerPriority-2.lua"),
),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on other ports, logic of script doesn't change only removing extra pause key

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but was this functionality actually working on all the ports?

Keys.paused(ctx),
Keys.meta(ctx),
Keys.prioritized(ctx),
Keys.pc(ctx),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong keys being provided

Comment thread elixir/lib/bullmq/scripts.ex Outdated
]

args = [if(paused?, do: "paused", else: "resumed")]
args = [if(paused?, do: "paused", else: "resumed"), '1']

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing to emit event

|> maybe_add_opt("del", Map.get(job_opts, :delay) || Map.get(job_opts, "delay") || delay, 0)
|> maybe_add_opt(
"pri",
"priority",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not save short version of priority in node

@roggervalf
roggervalf force-pushed the getCountsPerPriority branch 3 times, most recently from 703d9ef to 6c58a0e Compare August 9, 2026 07:25
local waitKey = KEYS[1]
local pausedKey = KEYS[2]
local prioritizedKey = KEYS[4]
local prioritizedKey = KEYS[2]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must have been broken in all ports as it is using an invalid key, are we lacking tests to cover for this functionality?

@roggervalf roggervalf Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed all ports:

  • dotnet: added missing test cases and missed getCountsPerPriority method
  • php: it´s covered by test cases in pause and getCountsPerPriority
  • python: same as above
  • rust: same as above

@roggervalf roggervalf changed the title feat(queue): support getCountsPerPriority method [elixir] feat(queue): support getCountsPerPriority method [elixir] [dotnet] Aug 11, 2026
@roggervalf
roggervalf force-pushed the getCountsPerPriority branch from dc3373f to 20a0ded Compare August 11, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants