Skip to main content

A distributed unique ID generator inspired by Twitter's Snowflake.

Project description

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

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.3.0.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distributions

sonyflake_py-1.3.0-py3.9.egg (4.3 kB view hashes)

Uploaded Source

sonyflake_py-1.3.0-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page