From 449466ef7a226a9c1dff4253f68bf427bfba6103 Mon Sep 17 00:00:00 2001 From: Juwon Oluwadare Date: Tue, 24 Nov 2026 00:41:45 +0100 Subject: [PATCH] Document that concurrency key procs receive all job arguments The key is computed with instance_exec(*arguments, &key), so a lambda that takes fewer parameters than the arguments the job is enqueued with raises ArgumentError when enqueuing. This is easy to miss when the job has optional or keyword arguments, as the lambda works until the job is enqueued with them. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac408f7a6..896496d7a 100644 --- a/README.md +++ b/README.md @@ -539,7 +539,7 @@ class MyJob < ApplicationJob # ... ``` -- `key` is the only required parameter, and it can be a symbol, a string or a proc that receives the job arguments as parameters and will be used to identify the jobs that need to be limited together. If the proc returns an Active Record record, the key will be built from its class name and `id`. +- `key` is the only required parameter, and it can be a symbol, a string or a proc that receives the job arguments as parameters and will be used to identify the jobs that need to be limited together. If the proc returns an Active Record record, the key will be built from its class name and `id`. The proc is called with all the arguments the job is enqueued with, including optional and keyword arguments, so if you use a lambda, which is strict about the number of arguments it gets, make sure it accepts all of them. For example, use `->(contact, *) { contact }` if the job takes more arguments than the key needs. Otherwise, enqueuing the job with those arguments will raise an `ArgumentError`. - `to` is `1` by default. - `duration` is set to `SolidQueue.default_concurrency_control_period` by default, which itself defaults to `3 minutes`, but that you can configure as well. - `group` is used to control the concurrency of different job classes together. It defaults to the job class name.