Update FastAPI + Redis example

This commit is contained in:
Roman Mogylatov 2022-12-18 21:35:43 -05:00
parent f0d9eda566
commit 88a2b96102
4 changed files with 27 additions and 35 deletions

View File

@ -14,6 +14,7 @@ Development version
- Update CI/CD to ``actions/checkout@v3``, ``actions/setup-python@v4``, ``actions/upload-artifact@v3``, ``pypa/cibuildwheel@v2.11.3``, - Update CI/CD to ``actions/checkout@v3``, ``actions/setup-python@v4``, ``actions/upload-artifact@v3``, ``pypa/cibuildwheel@v2.11.3``,
and ``actions/download-artifact@v3``. and ``actions/download-artifact@v3``.
- Fix install crash on non-utf8 systems `#644 <https://github.com/ets-labs/python-dependency-injector/pull/644>`_. - Fix install crash on non-utf8 systems `#644 <https://github.com/ets-labs/python-dependency-injector/pull/644>`_.
- Update FastAPI Redis example to use ``aioredis`` version 2 `#613 <https://github.com/ets-labs/python-dependency-injector/pull/613>`_.
- Regenerate C sources using Cython 0.29.32. - Regenerate C sources using Cython 0.29.32.
4.40.0 4.40.0

View File

@ -1,4 +1,4 @@
FROM python:3.9-buster FROM python:3.10-buster
ENV PYTHONUNBUFFERED=1 ENV PYTHONUNBUFFERED=1

View File

@ -24,35 +24,26 @@ The output should be something like:
.. code-block:: .. code-block::
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=1, just started fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 04 Jan 2022 02:42:14.115 # Configuration loaded fastapi-redis-redis-1 | 1:C 19 Dec 2022 02:33:02.484 # Configuration loaded
redis_1 | 1:M 04 Jan 2022 02:42:14.116 * Running mode=standalone, port=6379. fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 * monotonic clock: POSIX clock_gettime
redis_1 | 1:M 04 Jan 2022 02:42:14.116 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 * Running mode=standalone, port=6379.
redis_1 | 1:M 04 Jan 2022 02:42:14.116 # Server initialized fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.485 # Server initialized
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * Loading RDB produced by version 6.0.9 fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * Loading RDB produced by version 7.0.5
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * RDB age 1 seconds fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * RDB age 58 seconds
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * RDB memory usage when created 0.77 Mb fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * RDB memory usage when created 0.85 Mb
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * DB loaded from disk: 0.000 seconds fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * Done loading RDB, keys loaded: 0, keys expired: 0.
redis_1 | 1:M 04 Jan 2022 02:42:14.117 * Ready to accept connections fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.487 * DB loaded from disk: 0.000 seconds
redis_1 | 1:signal-handler (1609728137) Received SIGTERM scheduling shutdown... fastapi-redis-redis-1 | 1:M 19 Dec 2022 02:33:02.488 * Ready to accept connections
redis_1 | 1:M 04 Jan 2022 02:42:17.984 # User requested shutdown... fastapi-redis-example-1 | INFO: Started server process [1]
redis_1 | 1:M 04 Jan 2022 02:42:17.984 # Redis is now ready to exit, bye bye... fastapi-redis-example-1 | INFO: Waiting for application startup.
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo fastapi-redis-example-1 | INFO: Application startup complete.
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # Redis version=6.0.9, bits=64, commit=00000000, modified=0, pid=1, just started fastapi-redis-example-1 | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
redis_1 | 1:C 04 Jan 2022 02:42:22.035 # Configuration loaded fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * Running mode=standalone, port=6379. fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET /favicon.ico HTTP/1.1" 404 Not Found
redis_1 | 1:M 04 Jan 2022 02:42:22.037 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
redis_1 | 1:M 04 Jan 2022 02:42:22.037 # Server initialized fastapi-redis-example-1 | INFO: 172.18.0.1:63998 - "GET / HTTP/1.1" 200 OK
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * Loading RDB produced by version 6.0.9
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * RDB age 9 seconds
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * RDB memory usage when created 0.77 Mb
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 04 Jan 2022 02:42:22.037 * Ready to accept connections
example_1 | INFO: Started server process [1]
example_1 | INFO: Waiting for application startup.
example_1 | INFO: Application startup complete.
example_1 | INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
Test Test
---- ----
@ -69,9 +60,9 @@ The output should be something like:
.. code-block:: .. code-block::
platform linux -- Python 3.9, pytest-6.2.1, py-1.10.0, pluggy-0.13.1 platform linux -- Python 3.10.9, pytest-7.2.0, pluggy-1.0.0
rootdir: /code rootdir: /code
plugins: cov-2.10.1, asyncio-0.14.0 plugins: cov-4.0.0, asyncio-0.20.3
collected 1 item collected 1 item
fastapiredis/tests.py . [100%] fastapiredis/tests.py . [100%]
@ -80,10 +71,10 @@ The output should be something like:
Name Stmts Miss Cover Name Stmts Miss Cover
------------------------------------------------- -------------------------------------------------
fastapiredis/__init__.py 0 0 100% fastapiredis/__init__.py 0 0 100%
fastapiredis/application.py 15 0 100% fastapiredis/application.py 14 0 100%
fastapiredis/containers.py 6 0 100% fastapiredis/containers.py 6 0 100%
fastapiredis/redis.py 7 4 43% fastapiredis/redis.py 7 4 43%
fastapiredis/services.py 7 3 57% fastapiredis/services.py 7 3 57%
fastapiredis/tests.py 18 0 100% fastapiredis/tests.py 18 0 100%
------------------------------------------------- -------------------------------------------------
TOTAL 53 7 87% TOTAL 52 7 87%

View File

@ -1,7 +1,7 @@
dependency-injector dependency-injector
fastapi fastapi
uvicorn uvicorn
aioredis<2 # TODO: Update example to work with aioredis >= 2.0 aioredis
# For testing: # For testing:
pytest pytest