Skip to content

Commit

Permalink
πŸ“ Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarbar338 authored Jun 24, 2021
1 parent 9fe193f commit 04d0e61
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,29 @@ package main
import "github.com/barbarbar338/snowflake"

func main() {
s := snowflake.Snowflake {
EPOCH: 1618606800, // your projects EPOCH
}
// create a new factory with your projects EPOCH and machineID
s := snowflake.NewFactory(1420070400000, 0)

id := s.Generate() // Some unique snowflake ID (eg: 6782465263234318336)
id := s.Generate() // Some unique snowflake ID (eg: 17447384661725548544)
}
```

# πŸ’» How It Works?

```
EPOCH: 1618606800
Snowflake: 6782465263234318336
EPOCH: 1420070400000
Snowflake: 17447384661725548544
Binary: 101111000100000001010000011100011001100100000100000000000000000
Timestamp: 1617065730866
WorkerID: 1
ProcessID: 0
Increment: 0
Binary: 1011110001000000010100000111000110011001000001000000000000
Timestamp: 4159708641244
MachineID: 1
Sequence: 0
●------------------------------------------------------------------------●
●-----------------------------------------------------------------●
β•” Binary β•—
β•‘10111100010000000101000001110001100110010β•‘ β•‘00001β•‘ β•‘00000β•‘ β•‘000000000000β•‘
β•š Timestamp ╝ β•š WID ╝ β•š PID ╝ β•š Increment ╝
β•” Binary β•—
β•‘10111100010000000101000001110001100110010β•‘ β•‘00001β•‘ β•‘000000000000β•‘
β•š Timestamp ╝ β•š MID ╝ β•š Sequence ╝
```

# 🧦 Contributing
Expand Down

0 comments on commit 04d0e61

Please sign in to comment.