module
Mosquito::UniqueJob::ClassMethods
Defined in:
mosquito/unique_job.crInstance Method Summary
-
#unique_for(duration : Time::Span)
Configures job uniqueness for this job.
Instance Method Detail
def unique_for(duration : Time::Span)
#
Configures job uniqueness for this job.
duration controls how long the uniqueness lock is held. After this
period expires, the same job can be enqueued again.
key is an array of parameter names (as strings) used to compute the
uniqueness key. When omitted, all parameters are used by default.
class SendEmailJob < Mosquito::QueuedJob
include Mosquito::UniqueJob
unique_for 1.hour
param user_id : Int64
param email_type : String
def perform
# ...
end
end
With a key filter:
class SendEmailJob < Mosquito::QueuedJob
include Mosquito::UniqueJob
unique_for 1.hour, key: [:user_id, :email_type]
param user_id : Int64
param email_type : String
param metadata : String
def perform
# ...
end
end