# These functions encapsulate various job utilities.
# They must be simple and free from side effects.
defvalidate(item)
raise(ArgumentError,"Job must be a Hash with 'class' and 'args' keys: `#{item}`")unlessitem.is_a?(Hash)&&item.key?("class")&&item.key?("args")
raise(ArgumentError,"Job args must be an Array: `#{item}`")unlessitem["args"].is_a?(Array)
raise(ArgumentError,"Job class must be either a Class or String representation of the class name: `#{item}`")unlessitem["class"].is_a?(Class)||item["class"].is_a?(String)
raise(ArgumentError,"Job 'at' must be a Numeric timestamp: `#{item}`")ifitem.key?("at")&&!item["at"].is_a?(Numeric)
raise(ArgumentError,"Job tags must be an Array: `#{item}`")ifitem["tags"]&&!item["tags"].is_a?(Array)
raise(ArgumentError,"Job must include a valid queue name")ifitem["queue"].nil?||item["queue"]==""
item["class"]=item["class"].to_s
item["queue"]=item["queue"].to_s
item["jid"]||=SecureRandom.hex(12)
item["created_at"]||=Time.now.to_f
item
end
defnormalized_hash(item_class)
ifitem_class.is_a?(Class)
raise(ArgumentError,"Message must include a Sidekiq::Worker class, not class name: #{item_class.ancestors.inspect}")unlessitem_class.respond_to?("get_sidekiq_options")