Skip to content

Add Initial Snowflake ID Support #670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 16, 2025
Merged

Conversation

downdawn
Copy link
Collaborator

No description provided.

@downdawn
Copy link
Collaborator Author

1、雪花id要64位,默认id的int类型是32位,看是否需要统一

2、本想参考使用snowflakekit
但是由于我们自定义了_asyncio,会出现异常,包括使用loguru\asyncio

from loguru import logger
import asyncio
        
        
  File "\Lib\asyncio\futures.py", line 430, in <module>
    Future = _CFuture = _asyncio.Future
                        ^^^^^^^^^^^^^^^
AttributeError: module '_asyncio' has no attribute 'Future'

@wu-clan
Copy link
Member

wu-clan commented Jun 15, 2025

对于算法而言,本身为 CPU 密集型,非 io 密集型使用异步往往不会提升性能,反而降低,所以使用同步应该是对的

@downdawn
Copy link
Collaborator Author

你是对的,我们还有一个问题:id类型要不要统一设置为BigInteger,如果要兼容雪花id的话

@wu-clan
Copy link
Member

wu-clan commented Jun 15, 2025

我已提交相关更新,请查阅

雪花 ID 被定义为可选项,值得注意的是,目前缺少相匹配的 sql 脚本,或许我们也应该添加

@wu-clan
Copy link
Member

wu-clan commented Jun 15, 2025

更多注意事项将通过文档进行添加

@downdawn downdawn changed the title 新增雪花算法ID实现 Add Initial Snowflake ID Support Jun 16, 2025
@downdawn
Copy link
Collaborator Author

引用了from backend.common.exception import errors,没法直接写测试代码,问题二还存在,_asyncio错误

@wu-clan
Copy link
Member

wu-clan commented Jun 16, 2025

_asyncio 直接在源文件执行 main 方法会触发,没仔细研究,改个文件名就行了

引用 errors 没啥阻碍吧

@downdawn
Copy link
Collaborator Author

我说的是同一个问题,_asyncio改个文件名吧,改了就可以

@wu-clan wu-clan merged commit 7afd841 into fastapi-practices:master Jun 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants