Skip to content

Conversation

@spight-zz
Copy link

Separating the map_args functionality away from redis_key method in order to allow the user to easily redefine the hashed args.

For example, I have a job that accepts certain information about the original user:

def self.perform(approval_id, approver_id)
  ...
end

But I want the job to be unique only by the approval_id parameter. The solution after my change would be to simply overwrite map_args:

def self.map_args(args)
  args[0]
end

Comment on lines +27 to 29
args = map_args(args)

digest = Digest::MD5.hexdigest(encode(class: job, args: args))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably rename the helper method encode_args, or maybe canonicalize_args, because that describes what it does instead of how it does it.

Then this would become:

Suggested change
args = map_args(args)
digest = Digest::MD5.hexdigest(encode(class: job, args: args))
digest = Digest::MD5.hexdigest(encode({ class: job, args: encode_args(args) }))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants