This release is a pre-release and may not be stable for production use.
Modern Flask
性能基准
以 gunicorn 为服务器,以 --workers 1 --threads 1 为性能基准
目的是为了在容器环境下,以 1 CPU 为基准进行调度
配置
Flask.config
使用环境变量 CONFIG_SOURCE 来判断配置来源,只支持 Python 类型
- 本地文件
xxxx.py
- Kubernetes 资源
kubernetes://[NAMESPACE]/configmaps/[NAME]/[KEY]kubernetes://[NAMESPACE]/secrets/[NAME]/[KEY]kubernetes://configmaps/[NAME]/[KEY]kubernetes://secrets/[NAME]/[KEY]
- HTTP 资源
http://xxxxx.xxxx/xxxx.pyhttps://xxxxx.xxxx/xxxx.py
默认为本地文件 config.py
可观测性
可观测性框架基于 OpenTelemetry,使用 Zipkin 作为导出格式
默认启用了对以下组件的观测
- logging
- flask
- sqlalchemy
- redis
可以使用 Flask.config 的 SERVICE_NAME 自定义 service.name
配置来源于标准环境变量,详细参考:
- https://opentelemetry-python.readthedocs.io/en/latest/exporter/zipkin/zipkin.html
- https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/logging/logging.html
指标使用 Prometheus,暴露于 /metrics 路径下
数据库
使用 SQLAlchemy 库
Engine 配置来自于 Flask.config, 前缀 DATABASE_ENGINE_, 参考配置如下:
DATABASE_ENGINE_URL = "sqlite+pysqlite:///:memory:"
DATABASE_ENGINE_ECHO = True
DATABASE_ENGINE_FUTURE = True
Session 配置来自于 Flask.config, 前缀 DATABASE_SESSION_, 参考配置如下:
DATABASE_SESSION_AUTOFLUSH = False
Redis
使用 Redis 库, 配置来自于 Flask.config, 前缀 REDIS_, 参考配置如下:
REDIS_HOST = "127.0.0.1"
详细参考 https://github.com/redis/redis-py/blob/12c17bfc436ea6784bbc8b2d327d981520858eb7/redis/client.py#L853
存储
目前只支持 腾讯云 COS 和 阿里云 OSS
配置来自于 Flask.config,前缀 STORAGE_,参考配置如下
腾讯云 COS
STORAGE_VENDOR = "cos"
STORAGE_SECRET_ID = "xxxxxxxxx"
STORAGE_SECRET_KEY = "xxxxxxxxx"
STORAGE_REGION = "ap-guangzhou"
STORAGE_ENDPOINT = "xxx.xxx.com"
阿里云 OSS
STORAGE_VENDOR = "oss"
STORAGE_ACCESS_KEY_ID = ""
STORAGE_ACCESS_KEY_SECRET = ""
STORAGE_ENDPOINT = ""
STORAGE_BUCKET = ""
详细参考 https://pypi.org/project/oss2/
许可证
Guo Y.K., MIT License
Metadata
Release files for modern-flask 202112b4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| modern-flask-202112b4.tar.gz | 8.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| modern_flask-202112b4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / modern-flask-202112b4.tar.gz
| Download URL | modern-flask-202112b4.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fc56d9f865662c975008f2fc3ce9ae647fcd9427ab1dba23fa35368bdf860b3
|
|
BLAKE2b-256 checksum How to use checksums |
4ce956406497ded2f35524c4da98709b355435b6c56ca52baeae35b5def3f645
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / modern_flask-202112b4-py3-none-any.whl
| Download URL | modern_flask-202112b4-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
83c48ce73dbc0fe0bca7ca58d194bb4898e56640d0c78196169994c7aa1656c0
|
|
BLAKE2b-256 checksum How to use checksums |
0a8284cf062c757ae7fe20a0f3677b63e51ff49a86dbf9b150d2362659621d97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|