Skip to content

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

License

Notifications You must be signed in to change notification settings

hjpotter92/sonyflake-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

90239ec · Aug 16, 2024

History

36 Commits
Aug 9, 2024
Jun 24, 2021
Aug 9, 2024
Aug 9, 2024
Feb 24, 2021
Mar 23, 2021
Mar 17, 2021
Mar 17, 2021
Jan 3, 2021
Aug 9, 2024
Mar 18, 2021
Mar 17, 2021
Mar 18, 2021
Feb 24, 2021
Jun 24, 2021

Repository files navigation

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 an integer value upto 16-bits, callable or None (will be used random machine id).

License

The MIT License (MIT).