Skip to content

A distributed unique ID generator inspired by Twitter's Snowflake, rewritten in elixir.

Notifications You must be signed in to change notification settings

hjpotter92/sonyflake-ex

Repository files navigation

sonyflake-ex

codecov Build Status

Sonyflake is a distributed unique ID generator inspired by Twitter's Snowflake.

This is an elixir rewrite of the original 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:

{:sonyflake_ex, "~> 0.1.0", hex: :sonyflake}

Quickstart

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).