https://github.com/hjpotter92/sonyflake-ex
A distributed unique ID generator inspired by Twitter's Snowflake, rewritten in elixir.
https://github.com/hjpotter92/sonyflake-ex
elixir id-generator snowflake sonyflake unique-id
Last synced: 9 months ago
JSON representation
A distributed unique ID generator inspired by Twitter's Snowflake, rewritten in elixir.
- Host: GitHub
- URL: https://github.com/hjpotter92/sonyflake-ex
- Owner: hjpotter92
- Created: 2021-04-08T10:21:23.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-09-03T20:44:06.000Z (almost 3 years ago)
- Last Synced: 2024-09-19T04:07:24.529Z (almost 2 years ago)
- Topics: elixir, id-generator, snowflake, sonyflake, unique-id
- Language: Elixir
- Homepage: https://hex.pm/packages/sonyflake
- Size: 19.5 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sonyflake-ex
[![codecov][codecov-badge]][codecov] [![Build Status][travis-ci-badge]][travis-ci]
Sonyflake is a distributed unique ID generator inspired by [Twitter's
Snowflake](https://blog.twitter.com/2010/announcing-snowflake).
This is an elixir rewrite of the original
[sony/sonyflake](https://github.com/sony/sonyflake) project, written
in Go.
A Sonyflake ID is composed of
39 bits for time in units of 10 msec
8 bits for a sequence number
16 bits for a machine id
## Installation
Add the package `sonyflake` to the list of dependencies in `mix.exs`:
```elixir
{:sonyflake_ex, "~> 0.1.0", hex: :sonyflake}
```
## Quickstart
``` elixir
sf = Sonyflake.new()
{:ok, sf, id} = Sonyflake.next_id(sf)
IO.puts(id)
```
There is a `Sonyflake.Setting` submodule to configure the
generator. API docs can be found autogenerated on [hexdocs].
## License
The MIT License (MIT).
[codecov]: https://codecov.io/gh/hjpotter92/sonyflake-ex
[codecov-badge]: https://codecov.io/gh/hjpotter92/sonyflake-ex/branch/main/graph/badge.svg?token=C0gJpcbuXe
[hexdocs]: https://hexdocs.pm/sonyflake/
[travis-ci]: https://travis-ci.com/hjpotter92/sonyflake-ex
[travis-ci-badge]: https://travis-ci.com/hjpotter92/sonyflake-ex.svg?branch=main