Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cristalhq/fastid
Fast ID generator based on timestamp, sequence number and worker id.
https://github.com/cristalhq/fastid
concurrency dependency-free go golang id-generator
Last synced: about 2 months ago
JSON representation
Fast ID generator based on timestamp, sequence number and worker id.
- Host: GitHub
- URL: https://github.com/cristalhq/fastid
- Owner: cristalhq
- License: mit
- Created: 2019-06-29T12:50:52.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-11T17:58:38.000Z (11 months ago)
- Last Synced: 2024-06-19T20:52:24.512Z (7 months ago)
- Topics: concurrency, dependency-free, go, golang, id-generator
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fastid
[![build-img]][build-url]
[![pkg-img]][pkg-url]
[![reportcard-img]][reportcard-url]
[![coverage-img]][coverage-url]Fast ID generator based on timestamp, sequence number and worker id.
## Rationale
Generating IDs quickly is a common task. Making this quickly is a nice thing to have.
## Features
* Simple.
* Thread-safe.
* Time based.
* Dependency-free.## Install
```
go get github.com/cristalhq/fastid
```## Example
```go
gen, err := NewGenerator(100, 200)id := gen.Next()
ts, seq, w := id.Parts()
ts = id.Timestamp()
seq = id.Sequence()
w = id.WorkerID()
```## Documentation
See [these docs][pkg-url].
## License
[MIT License](LICENSE).
[build-img]: https://github.com/cristalhq/fastid/workflows/build/badge.svg
[build-url]: https://github.com/cristalhq/fastid/actions
[pkg-img]: https://pkg.go.dev/badge/cristalhq/fastid
[pkg-url]: https://pkg.go.dev/github.com/cristalhq/fastid
[reportcard-img]: https://goreportcard.com/badge/cristalhq/fastid
[reportcard-url]: https://goreportcard.com/report/cristalhq/fastid
[coverage-img]: https://codecov.io/gh/cristalhq/fastid/branch/master/graph/badge.svg
[coverage-url]: https://codecov.io/gh/cristalhq/fastid