-
Notifications
You must be signed in to change notification settings - Fork 91
Open
Description
i wanted to have a shared rule per job but have a limit of something per key ( per organization )
Sidekiq::Throttled::Registry.add(
:shared_throttling_rule,
concurrency: [
{ limit: 10, key_suffix: ->(args) { args['org_id'] || 'default' } }
]
)
and then I wanted different jobs to share the same limit per organization
class TesteOneJob < ApplicationJob
include Sidekiq::Throttled::Worker
sidekiq_throttle_as :shared_throttling_rule
def perform(job_number, org_id:)
Rails.logger.debug "Performing TesteOneJob #{job_number} for organization #{org_id} at #{Time.zone.now}"
sleep(1)
Rails.logger.debug "Finished TesteOneJob #{job_number} at #{Time.zone.now}"
end
end
class TesteJob < ApplicationJob
include Sidekiq::Throttled::Worker
sidekiq_throttle_as :shared_throttling_rule
def perform(job_number, org_id:)
Rails.logger.debug "Performing TesteJob #{job_number} for organization #{org_id} at #{Time.zone.now}"
sleep(1)
Rails.logger.debug "Finished TesteJob #{job_number} at #{Time.zone.now}"
end
end
Reactions are currently unavailable