Add download_dump endpoint

This commit is contained in:
2022-08-21 14:15:25 +03:00
parent eb9cf2fe29
commit 0d252fc532
8 changed files with 109 additions and 62 deletions

View File

@@ -6,6 +6,7 @@ from prometheus_fastapi_instrumentator import Instrumentator
from app.views import router, healthcheck_router
from core.arq_pool import get_arq_pool
from core.db import database
from core.redis_client import get_client
import core.sentry # noqa: F401
@@ -24,6 +25,7 @@ def start_app() -> FastAPI:
await database_.connect()
app.state.arq_pool = await get_arq_pool()
app.state.redis_client = get_client()
@app.on_event("shutdown")
async def shutdown() -> None:

9
src/core/redis_client.py Normal file
View File

@@ -0,0 +1,9 @@
import aioredis
from core.config import env_config
def get_client() -> aioredis.Redis:
return aioredis.Redis(
host=env_config.REDIS_HOST, port=env_config.REDIS_PORT, db=env_config.REDIS_DB
)

View File

@@ -1,13 +1,11 @@
import aioredis
from app.services.cache_updater import (
check_books,
cache_file_by_book_id,
check_books_page,
)
from core.arq_pool import get_redis_settings, get_arq_pool
from core.config import env_config
from core.db import database
from core.redis_client import get_client
import core.sentry # noqa: F401
@@ -16,9 +14,7 @@ async def startup(ctx):
await database.connect()
ctx["arc_pool"] = await get_arq_pool()
ctx["redis"] = aioredis.Redis(
host=env_config.REDIS_HOST, port=env_config.REDIS_PORT, db=env_config.REDIS_DB
)
ctx["redis"] = get_client()
async def shutdown(ctx):