Initial commit
All checks were successful
Run linters on applied template / Python 3.13 lint and build (push) Successful in 56s
All checks were successful
Run linters on applied template / Python 3.13 lint and build (push) Successful in 56s
This is a FastAPI backend microservice template used with `copier` utility. Features of applied template are: - Configuration file processing logic - Metrics and tracing (both optional) configuration available - Debug endpoints - Database migration commands, prepared Alembic environment - Database usage example in ping_db endpoint - gitea sanity check pipeline
This commit is contained in:
1
{{project_slug}}/logic/__init__.py
Normal file
1
{{project_slug}}/logic/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Handlers logic functions are located here."""
|
||||
16
{{project_slug}}/logic/system.py.jinja
Normal file
16
{{project_slug}}/logic/system.py.jinja
Normal file
@@ -0,0 +1,16 @@
|
||||
"""/system handlers logic is defined here."""
|
||||
|
||||
from sqlalchemy import select, text
|
||||
|
||||
from {{project_slug}}.db.connection.manager import PostgresConnectionManager
|
||||
from {{project_slug}}.schemas.health_check import PingResponse
|
||||
|
||||
|
||||
async def ping_db(connection_manager: PostgresConnectionManager, readonly: bool) -> PingResponse:
|
||||
conn_future = connection_manager.get_connection() if not readonly else connection_manager.get_ro_connection()
|
||||
|
||||
query = select(text("1"))
|
||||
async with conn_future as conn:
|
||||
res = (await conn.execute(query)).scalar_one()
|
||||
if res == 1:
|
||||
return PingResponse()
|
||||
Reference in New Issue
Block a user