Snakeflake is a discrete nonserial ID generator like Snowflake implemented in Python
Project description
Snakeflake
Snakeflake is a discrete nonserial ID generator like Snowflake and Sonyflake, implemented in Python.
"Discrete" and "nonserial" are real words. I promise.
Usage
>>> import datetime
>>> from snakeflake.snakeflake import SnakeflakeGenerator
>>> from snakeflake.config import SnakeflakeGeneratorConfig
>>>
>>> # Set the epoch to 5:30, 28 March 2010 and the machine ID to 283
>>> config = SnakeflakeGeneratorConfig(datetime.datetime(2010, 3, 28, 5, 30), 283)
>>> # Create the Snakeflake Generator
>>> sf = SnakeflakeGenerator(config)
>>> # Generate some Snakeflake IDs
>>> sf.next_id()
526063632593715483
>>> sf.next_id()
526063667423281435
>>> # Not specifying a Machine ID will generate one from your internal IP address
>>> config = SnakeflakeGeneratorConfig(datetime.datetime(2010, 3, 28, 5, 30), None)
>>> config.machine_id
1
Installation
You can install Snakeflake using pip:
pip install snakeflake
Documentation
View the documentation here.
To do:
- Better Documentation
- Add tests(!!!)
- Add a snakeflake decoder
- Publish (🎉🎉🎉)
-
Add an icon - Add a better icon
- Accept a function as a parameter to get the current machine id
- Accept a function as a parameter to check the uniqueness of the machine id
- Async support (if I decide to do the above)
Contributing
Want to contribute to this project? Feel free to submit a PR!
License
This project is licensed under the Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file snakeflake-0.1.5.2-py3.7.egg.
File metadata
- Download URL: snakeflake-0.1.5.2-py3.7.egg
- Upload date:
- Size: 12.8 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b50de9150090384860f62e403b2a1033faeb2ae6713eaeb377a5dba33195b844
|
|
| MD5 |
a89fd135d41b6e3b99358abf8c2c626c
|
|
| BLAKE2b-256 |
b4035bf5d148561a5db7a72eda8e03ac7e01c7a59405f11783e3c2729d02bf40
|
File details
Details for the file snakeflake-0.1.5.2-py3-none-any.whl.
File metadata
- Download URL: snakeflake-0.1.5.2-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
223cd399694b974dfd11de65328015b94cca06366e947b6caf72f80237fa9b0b
|
|
| MD5 |
c11a22749d33630f1c961259d4bd2589
|
|
| BLAKE2b-256 |
4114e9782fcf346d07a1eb9c6cde4cfefe9c4af03454643032869b6e68baa6c7
|