Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alindeman/crystal
[EXPERIMENTAL] Decentralized, k-ordered ID generation service in Go
https://github.com/alindeman/crystal
Last synced: about 1 month ago
JSON representation
[EXPERIMENTAL] Decentralized, k-ordered ID generation service in Go
- Host: GitHub
- URL: https://github.com/alindeman/crystal
- Owner: alindeman
- Created: 2014-07-02T17:40:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-07-20T01:29:07.000Z (over 10 years ago)
- Last Synced: 2024-10-20T07:43:21.533Z (2 months ago)
- Language: Go
- Homepage:
- Size: 2.37 MB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Crystal
Crystal is a decentralized, k-ordered id generation service. Run crystal on
each node in your infrastructure to generate conflict-free ids on-demand
without coordination.Crystal produces IDs in the same format as
(flake)[https://github.com/boundary/flake], but crystal is implemented in Go to
make deployment and interfacing with it a tad easier.For more information on the advantages of decentralized k-ordered IDs, see the
[Bounary blog post on
flake](http://www.boundary.com/blog/2012/01/12/flake-a-decentralized-k-ordered-unique-id-generator-in-erlang/).
Crystal is very similar to flake, but has no runtime dependencies on the Erlang
VM and can be interfaced with more easily in any language.## What's a k-ordered ID?
Crystal produces 128 bit k-ordered IDs. The first 64 bits is a timestamp, so
IDs are time-ordered lexically.The next 48 bits is a unique worker ID, usually set to the MAC address of a
machine's network interface, so IDs are conflict-free but without coordination.
You should run crystal locally on every node that needs to generate IDs.The final 16 bits is a sequence ID, incremented each time an ID is generated in
the same millisecond as a previous ID. The sequence is reset to 0 when time
advances.```
|--------------------------------|-------------------------|--------|
| 64 | 48 | 16 |
| Timestamp (ms) | Worker ID (MAC addr) | Seqn |
|--------------------------------|-------------------------|--------|
```