alexedwards / sonyflake-py

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

Home Page:https://pypi.org/project/sonyflake-py/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sonyflake-py

codecov Build Status Documentation Status

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

This is a python 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

pip install sonyflake-py

Quickstart

from sonyflake import SonyFlake
sf = SonyFlake()
next_id = sf.next_id()
print(next_id)

The generator can be configured with variety of options, such as custom machine_id, start_time etc.

  • start_time should be an instance of datetime.datetime.
  • machine_id should be a callable which returns an integer value upto 16-bits.

License

The MIT License (MIT).

About

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

https://pypi.org/project/sonyflake-py/

License:MIT License


Languages

Language:Python 100.0%