Latch. TID
(latch v0.5.0)
Copy Markdown
Timestamp identifiers, frequently used as record keys in atproto. Time-sortable, can be used as logical clocks within a system, and designed to reduce the risk of collisions.
Summary
Functions
Generate a TID that encodes the given time and a random clock ID, making it unlikely (but not impossible) to result in collisions.
Takes a raw integer and formats it as a TID.
Generate a TID that encodes the current time and a random clock ID, making it unlikely (but not impossible) to result in collisions.
Validates a given string against a regex to ensure it conforms with the spec.
Functions
@spec at_time(DateTime.t(), integer()) :: String.t()
Generate a TID that encodes the given time and a random clock ID, making it unlikely (but not impossible) to result in collisions.
Overriding :clock_id allows you to create deterministic tests.
@spec new(non_neg_integer()) :: String.t()
Takes a raw integer and formats it as a TID.
In most cases you'll want to use the helpers now and at_time.
Generate a TID that encodes the current time and a random clock ID, making it unlikely (but not impossible) to result in collisions.
Options
:clock_id- override the random clock ID:time_fun- a function that returns the current time as microseconds
Overriding both :clock_id and :time_fun allows you to create deterministic tests.
Validates a given string against a regex to ensure it conforms with the spec.