Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import asyncio
import logging
import os
import uuid
from contextlib import asynccontextmanager
from typing import Annotated
Expand Down Expand Up @@ -46,6 +47,7 @@ async def lifespan(app: FastAPI):

app: FastAPI = FastAPI(
title="Teams Notifier gitlab-mr-api",
version=os.environ.get("VERSION", "v0.0.0-dev"),
lifespan=lifespan,
middleware=[
Middleware(
Expand Down
4 changes: 4 additions & 0 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ async def connect(self):
init=self.init_connection,
)

# Simple check at startup, will validate database resolution and creds
async with await self.acquire() as connection:
await connection.fetchval("SELECT 1")

async def init_connection(self, conn: asyncpg.Connection) -> None:
log.debug("connecting to database")
await conn.set_type_codec("jsonb", encoder=json.dumps, decoder=json.loads, schema="pg_catalog")
Expand Down