firefly-utils 是 Firefly Python 的公共工具包,发布包名为 firefly-utils,导入根为
firefly.utils。
首期目标是沉淀各微服务都会用到、且不携带业务语义的基础能力,优先保持小而稳定:
firefly.utils.compress:gzip 压缩,以及可选zstandard依赖存在时的 zstd 压缩。firefly.utils.crypto:MD5 指纹、AES-GCM 加解密、RSA-OAEP 加解密与 RSA-PSS 签验。firefly.utils.network:按 Go 版本语义拆分host:port,缺省端口可配置。firefly.utils.tlsx:三证书字段齐全才启用的 TLS 配置模型。firefly.utils.slicex、structx、version、file:常用集合、结构、版本和文件辅助函数。
uv sync
uv run pytest
uv run ruff check src tests
uv run mypy
uv build --no-sourcesfromfirefly.utilsimportaes_gcm_decrypt, aes_gcm_encrypt, split_host_portkey=b"0"*32ciphertext=aes_gcm_encrypt(b"hello", key)
assertaes_gcm_decrypt(ciphertext, key) ==b"hello"host_port=split_host_port("127.0.0.1", "8080")
asserthost_port.host=="127.0.0.1"asserthost_port.port=="8080"- 本包只放跨模块通用能力,不放微服务、Redis、ORM 等领域逻辑。
firefly使用隐式 namespace package,包内不提供src/firefly/__init__.py。- 首个版本从
0.0.1开始,后续公共 API 需要按兼容性策略谨慎演进。