Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Its possible to use this gem like this ? #199

Open
brunomiguelpinto opened this issue Nov 20, 2024 · 4 comments
Open

Its possible to use this gem like this ? #199

brunomiguelpinto opened this issue Nov 20, 2024 · 4 comments

Comments

@brunomiguelpinto
Copy link

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
@brunomiguelpinto
Copy link
Author

I did some tests and it ignores what I specified I wanted to have the possibility to count different jobs with the same key and per organization

@ixti
Copy link
Owner

ixti commented Nov 21, 2024

The setup looks correct. Will need to figure out why does that not work.

@brunomiguelpinto
Copy link
Author

any news on this one ?

@ixti
Copy link
Owner

ixti commented Dec 11, 2024

Not yet, but I hope I will get to it soon - as I'm starting to use the gem with AJ myself ;D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants