A distributed unique ID generator inspired by Twitter's Snowflake.
Project description
sonyflake-py
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 ofdatetime.datetime
.machine_id
should be a callable which returns an integer value upto 16-bits.
License
The MIT License (MIT).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sonyflake-py-1.1.0.tar.gz
(3.4 kB
view hashes)
Built Distributions
sonyflake_py-1.1.0-py3.9.egg
(3.4 kB
view hashes)
Close
Hashes for sonyflake_py-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 711d19ccb8b5f886159cb17ae414a9470fc94d486545934c203332cfaae5958d |
|
MD5 | 7d90314afc59e6acf23e57aa5fe97f74 |
|
BLAKE2b-256 | 911e1089d18f40fca0c9411841d7b1817556bef9c35f3cfdb6cf749c5f2bcf10 |