Documentation
¶
Overview ¶
Package updatestamp is the per-record last-write stamp: one sortable token that keeps the timestamp and the device tiebreaker from ever drifting apart. It is the Go counterpart of lib/tasks/update_stamp.rb.
The whole value object lives here — validation, the ordering key, comparison, and formatting — because the stamp is what decides last-write-wins when two devices edited the same record. A second spelling of "which stamp is newer" living in the merge path would be a second answer waiting to diverge.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare orders two stamps the way UpdateStamp.compare does: -1, 0, or 1.
An unparseable or absent stamp sorts BEFORE every real one, and two of them compare equal. That is the rule last-write-wins depends on: a record whose stamp a hand edit destroyed must never win against a record that carries a real one, and it must not oscillate when neither side has one.
func Device ¶
func Device(env determinism.Env) string
Device is the device slug for this process: TASKS_DEVICE when it is set to anything but blank, otherwise the hostname — resolved through Determinism so that one pin covers both hostname consumers.
func Format ¶
Format renders the stamp a writer stores: the instant in UTC, then the device slug. Ruby additionally raises on an empty slug; Slug cannot return one (it falls back to "device"), so the guard is unreachable in both languages and is not reproduced as an error return.
func Key ¶
Key is the ordering key of a stamp: its timestamp half and its device half, or ok=false when the value is not a stamp at all. The two are compared in that order, which is why the stored spelling is one token — sorting the file by `updated` and sorting it by (timestamp, device) are the same sort.
func Max ¶
Max is the later of two stamps, preferring the LEFT one on a tie — the same bias Ruby's `compare(left, right).negative? ? right : left` has, so a merge that finds two equal stamps keeps the value it already held.
Types ¶
This section is empty.