Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hjpotter92/sonyflake-py
A distributed unique ID generator inspired by Twitter's Snowflake, rewritten in python
https://github.com/hjpotter92/sonyflake-py
codecov codecov-badge id-generator python readthedocs readthedocs-badge snowflake sonyflake travis-ci unique-id
Last synced: 5 days ago
JSON representation
A distributed unique ID generator inspired by Twitter's Snowflake, rewritten in python
- Host: GitHub
- URL: https://github.com/hjpotter92/sonyflake-py
- Owner: hjpotter92
- License: mit
- Created: 2021-01-03T18:51:11.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-17T15:35:54.000Z (4 months ago)
- Last Synced: 2024-12-03T10:43:02.696Z (19 days ago)
- Topics: codecov, codecov-badge, id-generator, python, readthedocs, readthedocs-badge, snowflake, sonyflake, travis-ci, unique-id
- Language: Python
- Homepage: https://pypi.org/project/sonyflake-py/
- Size: 24.4 KB
- Stars: 35
- Watchers: 4
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sonyflake-py
[![codecov][codecov-badge]][codecov] [![Build Status][travis-ci-badge]][travis-ci] [![Documentation Status][readthedocs-badge]][readthedocs]
Sonyflake is a distributed unique ID generator inspired by [Twitter's
Snowflake](https://blog.twitter.com/2010/announcing-snowflake).This is a python rewrite of the original
[sony/sonyflake](https://github.com/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
``` shell
pip install sonyflake-py
```## Quickstart
``` python
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).
[codecov]: https://codecov.io/gh/hjpotter92/sonyflake-py
[codecov-badge]: https://codecov.io/gh/hjpotter92/sonyflake-py/branch/master/graph/badge.svg?token=XZCRNSSSQK
[readthedocs]: http://sonyflake-py.rtfd.io/
[readthedocs-badge]: https://readthedocs.org/projects/sonyflake-py/badge/?version=latest
[travis-ci]: https://travis-ci.com/hjpotter92/sonyflake-py
[travis-ci-badge]: https://travis-ci.com/hjpotter92/sonyflake-py.svg?branch=master