- Add test environment to __init__.py for all eveai services

- Add postgresql certificate to secrets for secure communication in staging and production environments
- Adapt for TLS communication with PostgreSQL
- Adapt tasks to handle invalid connections from the connection pool
- Migrate to psycopg3 for connection to PostgreSQL
This commit is contained in:
Josako
2025-09-10 11:40:38 +02:00
parent 6fbaff45a8
commit 6ccba7d1e3
15 changed files with 116 additions and 11 deletions

View File

@@ -17,6 +17,10 @@ def create_app(config_file=None):
match environment:
case 'development':
app.config.from_object(get_config('dev'))
case 'test':
app.config.from_object(get_config('test'))
case 'staging':
app.config.from_object(get_config('staging'))
case 'production':
app.config.from_object(get_config('prod'))
case _:

View File

@@ -3,8 +3,9 @@ import os
from datetime import datetime as dt, timezone as tz, datetime
from flask import current_app
from celery import states
from sqlalchemy import or_, and_, text
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.exc import SQLAlchemyError, InterfaceError, OperationalError
from common.extensions import db
from common.models.user import Tenant
from common.models.entitlements import BusinessEventLog, LicenseUsage, License
@@ -20,8 +21,8 @@ def ping():
return 'pong'
@current_celery.task(name='persist_business_events', queue='entitlements')
def persist_business_events(log_entries):
@current_celery.task(bind=True, name='persist_business_events', queue='entitlements', autoretry_for=(InterfaceError, OperationalError), retry_backoff=True, retry_jitter=True, max_retries=5)
def persist_business_events(self, log_entries):
"""
Persist multiple business event logs to the database in a single transaction