Using Sidekiq Iteration and Unique Jobs


This will remove the sidekiq iteration hash from the arguments, so the sidekiq job will appear unique to unique jobs.

Couldn’t find this online so here is a quick fix.

class MyJob
  include Sidekiq::Job
  include SidekiqIteration::Iteration

  sidekiq_options queue: :default, lock: :until_and_while_executing, on_conflict: :reject

  def self.lock_args args
    if args.last.is_a?(Hash) && args.last.key?("sidekiq_iteration")
      args.take(args.length - 1)
    else
      args
    end
  end

  # ...

Refs

https://github.com/mhenrixon/sidekiq-unique-jobs https://github.com/fatkodima/sidekiq-iteration

Related Posts

Simple Explanation of the Pinyin Sounds

Failed Attempt at Creating a Video Search Engine

Test Your Chinese Using This Quiz

Using Radicale with Gnome Calendar

Why I Regret Switching from Jekyll to Middleman for My Blog

Pick Random Item Based on Probability

Quickest Way to Incorporate in Ontario

Creating Chinese Study Decks

Generating Better Random Numbers

Image Magick Tricks