项目作者: hjpotter92

项目描述 :
A distributed unique ID generator inspired by Twitter's Snowflake, rewritten in python
高级语言: Python
项目地址: git://github.com/hjpotter92/sonyflake-py.git
创建时间: 2021-01-03T18:51:11Z
项目社区:https://github.com/hjpotter92/sonyflake-py

开源协议:MIT License

下载


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

  1. 39 bits for time in units of 10 msec
  2. 8 bits for a sequence number
  3. 16 bits for a machine id

Installation

  1. pip install sonyflake-py

Quickstart

  1. from sonyflake import SonyFlake
  2. sf = SonyFlake()
  3. next_id = sf.next_id()
  4. 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).