Ant.WorkerUniquenessChecker (Ant v1.0.0)
Handles uniqueness checking for workers to prevent duplicate job creation.
Summary
Functions
Checks if a worker with the same unique attributes already exists.
Returns the key that concurrent creations of the same unique worker contend
on, or nil when the worker has no uniqueness configured.
Functions
Link to this function
call(worker)
@spec call(Ant.Worker.t()) :: :ok | {:error, :already_exists}
Checks if a worker with the same unique attributes already exists.
Returns :ok if no duplicate exists, or {:error, :already_exists} if a duplicate is found.
Link to this function
lock_key(worker)
@spec lock_key(Ant.Worker.t()) :: tuple() | nil
Returns the key that concurrent creations of the same unique worker contend
on, or nil when the worker has no uniqueness configured.
Two workers can only be duplicates of each other when they share a module, a queue and the values of every unique attribute, which is exactly what the key is built from.