This allows you to implement a custom unique hash function on the worker trait, so that when a job is enqueued with the unique_for(duration) option, a custom hash will be used instead of the generic sha256(to_json(args)) implementation.
It's a little clunky at this point, but I wanted to open a proof of concept PR to give time to think about how this should be implemented.
NOTE: While unique_for will work just fine without a worker trait being implemented (for workers implemented in other projects or other languages), this current implementation of uniq_hash_for_args is only defined on the worker trait. Otherwise, you'll need to specify a custom unique hash as you enqueue the worker. Example:
This allows you to implement a custom unique hash function on the worker trait, so that when a job is enqueued with the
unique_for(duration)
option, a custom hash will be used instead of the genericsha256(to_json(args))
implementation.It's a little clunky at this point, but I wanted to open a proof of concept PR to give time to think about how this should be implemented.
NOTE: While
unique_for
will work just fine without a worker trait being implemented (for workers implemented in other projects or other languages), this current implementation ofuniq_hash_for_args
is only defined on the worker trait. Otherwise, you'll need to specify a custom unique hash as you enqueue the worker. Example:It's nice that this will still work, but it's a little clunky.
Otherwise the impl looks like:
Naming isn't superb but it's functional.