Skip to content

clarification on unique_args #20

@barmstrong

Description

@barmstrong

Does the args filter need to return an array?
Or can it return any unique string (or object that responds to .hash, etc)?

For example would this work?

class SomeJob
  include Sidekiq::Worker
  sidekiq_options queue: :critical, unique: true, unique_args: :args_filter

  def self.args_filter(*args)
    args.first
  end

  def perform(object_id, attempts=1)
    ...
  end
end

Second question: does args_filter need to include the name of the job ("SomeJob" in this case)? Or is this added for you?

The docs don't make it super clear because they shown an example like this (but don't show the corresponding perform method signature, so it's unclear what these variables are actually referring to.

  def self.unique_args(name, id, options)
    [ name, options[:type] ]
  end

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions