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

Documentation regarding ActiveJob integration not clear #244

Closed
aaronsilverman opened this issue Sep 17, 2017 · 2 comments
Closed

Documentation regarding ActiveJob integration not clear #244

aaronsilverman opened this issue Sep 17, 2017 · 2 comments

Comments

@aaronsilverman
Copy link

aaronsilverman commented Sep 17, 2017

The README offers the following code snippet to integrate with activejob.

Sidekiq.default_worker_options = { unique: :until_executing, unique_args: ->(args) { [ args.first.except('job_id') ] } }

But does not state how to implement this code. A few questions I have:

  • Where do I put this code?
  • How do I customize it?
  • Why is it needed?

The documentation is very bear bones and is not understandable as it is currently written. A brief explanation would do wonders for integrating this very helpful gem with activejob.

@mprostko
Copy link

Let me answer your questions:

  • Typically you put this in config/initializers/sidekiq.rb along with other Sidekiq configuration options. Of course it can be defined in other initializer files.
  • Depends on what you want to customize. The array that is returned in unique_args it a set of 'attributes' that define the uniqueness of a job. Think of it as a multicolumn unique index (constraint) in a database.
  • It is needed because you cannot use Sidekiq specific options defined per sidekiq worker in ActiveJob because ActiveJob is a simple wrapper and does not pass those option to underlying Sidekiq workers (via ActiveJob::JobWrapper). Therefore you have to define those options as default_sidekiq_options but then you lose the ability to control specific worker/job configuration. For more info see https://github.com/rails/rails/blob/master/activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb

Although more advanced options control can be obtained by a 'hack' using concerns and including it directly into ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper

@aaronsilverman
Copy link
Author

Could this be included in the readme? I think it would help others.

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

3 participants