Documentation
¶
Overview ¶
Package unique validates unique-job options, selects the identifying argument fields and computes the period bucket. The canonical form and the hash are computed once, in SQL, by foreman_canonical_json, so every language that enqueues through SQL gets the same key; Go never hashes.
id, err := unique.Identity("email", "default", args, unique.Options{ByArgs: true}, now)
mask := unique.Mask(opts.States()) // "11111000"
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidOptions is wrapped by every validation error of Options. ErrInvalidOptions = errors.New("unique: invalid options") // ErrArgsNotCanonical reports a non-integral number in the unique // identity; foreman_canonical_json rejects it (SQLSTATE 22023). ErrArgsNotCanonical = errors.New("foreman: unique args not canonical") )
Errors of unique jobs.
View Source
var DefaultStates = []job.State{ job.StateAvailable, job.StateScheduled, job.StateRunning, job.StateRetryable, job.StateCompleted, }
DefaultStates are the states covered when ByState is empty.
Functions ¶
func Identity ¶
Identity builds the identity object whose canonical form Postgres hashes into unique_key: {"kind", "args"} plus "queue" when ByQueue and "period" when ByPeriod. args must be a JSON value; with ByArgFields it must be an object. Raw argument bytes are copied verbatim so numbers keep full precision.
Types ¶
Click to show internal directories.
Click to hide internal directories.