Skip to content

About

源自原 twitter 项目 snowflake 的 FastApi 服务端。

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-snowflake-server · GitHub license

源自原 twitter 项目 snowflake 的 FastApi 服务端。

结构

py-snowflake-server/
├─ logs/                      # 日志目录(启动时生成)
├─ src/                       # 业务源码根目录
│  ├─ __init__.py
│  ├─ main.py                 # 程序入口、uvicorn启动、全局异常、日志初始化
│  ├─ schemas/                # 数模
│  │  ├─ __init__.py
│  │  └─ response.py
│  ├─ core/
│  │  ├─ __init__.py
│  │  ├─ snowflake.py         # 雪花ID生成/解码
│  │  ├─ config.py            # 全局配置:epoch、worker_id、日志参数、端口等
│  │  └─ logger.py            # 独立日志工具
│  ├─ api/                    # 路由接口
│  │  ├─ __init__.py
│  │  └─ v1/
│  │     ├─ __init__.py
│  │     └─ snowflake_api.py  # 接口路由
│  └─ services/               # 业务逻辑层
│     ├─ __init__.py
│     └─ snowflake_service.py # ID生成、解码业务逻辑
├─ test/                      # 压测脚本
├─ poetry.lock
├─ pyproject.toml
├─ start.bat                  # 启动脚本
└─ README.md

启动

  1. 创建虚拟环境:poetry env use [python_path]
  2. 安装依赖:poetry install --no-root
  3. 使用 start.bat 启动

接口

  1. GET /snowflake/id 生成雪花ID
  2. GET /snowflake/decode/{id} 解析ID信息

License

py-snowflake-server is MIT license.

About

源自原 twitter 项目 snowflake 的 FastApi 服务端。

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages