Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separating the map_args functionaliy from redis_key #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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