module Sidekiq::JobUtil
def normalize_item(item)
def normalize_item(item) validate(item) # merge in the default sidekiq_options for the item's class and/or wrapped element # this allows ActiveJobs to control sidekiq_options too. defaults = normalized_hash(item["class"]) defaults = defaults.merge(item["wrapped"].get_sidekiq_options) if item["wrapped"].respond_to?(:get_sidekiq_options) item = defaults.merge(item) raise(ArgumentError, "Job must include a valid queue name") if item["queue"].nil? || item["queue"] == "" # remove job attributes which aren't necessary to persist into Redis TRANSIENT_ATTRIBUTES.each { |key| item.delete(key) } item["jid"] ||= SecureRandom.hex(12) item["class"] = item["class"].to_s item["queue"] = item["queue"].to_s item["retry_for"] = item["retry_for"].to_i if item["retry_for"] item["created_at"] ||= now_in_millis item end