Skip to content

cristalhq/fastid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastid

build-img pkg-img reportcard-img coverage-img

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

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.

License

MIT License.

About

Fast ID generator based on timestamp, sequence number and worker id.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Languages