Pysnowflake
Twitter Snowflake Server implemented in Python and Tornado for HTTP based ID generation
Install / Use
/learn @koblas/PysnowflakeREADME
pysnowflake
pysnowflake is a Python implementation of Twitter's snowflake service - https://github.com/twitter/snowflake
This is based on the pysnowflak python trift service that Erans did - https://github.com/erans/pysnowflake
Our use case wasn't thrift oriented but HTTP based, so this is a service that runs under the Tornado web framework. Which makes it possible to only have one depenancy (tornado).
Due to various reasons this implementation does not reach the performance indicated in the original Snowflake implementation, however it is good enough in most cases and can be combined with the help of a software load balancer such as HAProxy to run multiple processes to get higher performance.
Installation
- Install Tornado
- Run the service
Usage
usage: pysnowflake.py [--debug] [--port=9000] [--datacenter=DC_ID] [--worker=WORKER_ID]
Python based Snowflake server over HTTP
See the original snowflake server docs for a detailed description, but the bottom line is unique numbers will insure unique identifers generated. WORKER_ID is the identifier for this process DATACENTER_ID is the identifier for this datacenter
API (aka URLs):
/id/<USERAGENT> -- get a unique ID, <USERAGENT> is provided for metrics purposes
/timestamp/ -- get the current timestamp for this host
/datacenter/ -- get the data center identifier for this process
/worker/ -- get the data center identifier for this process
Issues
Please report any issues via github issues
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
