Closed danielgomezrico closed 5 years ago
I undestood badly the readme, it turns out that the key should receive a function that receive the same number of parameters as the perform
function of the worker:
ex:
class MyWorker
include Sidekiq::Worker
include Sidekiq::Throttled::Worker
sidekiq_options queue: "my_queue"
sidekiq_throttle({
:threshold => {
:limit => 100,
:period => 10.second,
:key_suffix => -> (_, _) { "my-key" }
}
})
def perform(call, email)
end
end
Otherwise the throttle does not work and each job run as fast as it can.
Mm, yes. You can pass Proc instead of Lambda so that it won't require to have same amount of args. These are different way of achieving that:
# Proc
proc { "my-key" }
proc { |*| "my-key" }
# Lambda
lambda { |*| "my-key" }
->(*) { "my-key" }
@ixti yeah it worked, thanks
Hi
What do you mean by some trouble?
I want to speficy a static key-suffix for multiple jobs, so I can throttle all of them togetter with the same setup using the same key.
Is that possible?
I tried putting a static key-suffix but that results in never throttling any job.