Implement central configuration, custom exceptions, logging utilities, Pydantic models, and Redis client for BitByLaw integration

- Added `config.py` for centralized configuration management including Sync, API, Advoware, EspoCRM, Redis, Logging, Calendar Sync, and Feature Flags.
- Created `exceptions.py` with a hierarchy of custom exceptions for integration errors, API errors, sync errors, and Redis errors.
- Developed `logging_utils.py` for a unified logging wrapper supporting structured logging and performance tracking.
- Defined Pydantic models in `models.py` for data validation of Advoware and EspoCRM entities, including sync operation models.
- Introduced `redis_client.py` for a centralized Redis client factory with connection pooling, automatic reconnection, and health checks.
This commit is contained in:
bsiggel
2026-03-03 17:18:49 +00:00
parent bcb6454b2a
commit 69a48f5f9a
12 changed files with 2118 additions and 321 deletions

View File

@@ -8,6 +8,16 @@ from typing import Dict, Any, Optional, List
from datetime import datetime
import logging
from services.models import (
AdvowareBeteiligteCreate,
AdvowareBeteiligteUpdate,
EspoCRMBeteiligteCreate,
validate_beteiligte_advoware,
validate_beteiligte_espocrm
)
from services.exceptions import ValidationError
from services.config import FEATURE_FLAGS
logger = logging.getLogger(__name__)
@@ -27,6 +37,9 @@ class BeteiligteMapper:
Returns:
Dict mit Stammdaten für Advoware API (POST/PUT /api/v1/advonet/Beteiligte)
Raises:
ValidationError: Bei Validierungsfehlern (wenn strict_validation aktiviert)
"""
logger.debug(f"Mapping EspoCRM → Advoware STAMMDATEN: {espo_entity.get('id')}")
@@ -78,6 +91,14 @@ class BeteiligteMapper:
logger.debug(f"Mapped to Advoware STAMMDATEN: name={advo_data.get('name')}, vorname={advo_data.get('vorname')}, rechtsform={advo_data.get('rechtsform')}")
# Optional: Validiere mit Pydantic wenn aktiviert
if FEATURE_FLAGS.strict_validation:
try:
validate_beteiligte_advoware(advo_data)
except ValidationError as e:
logger.warning(f"Validation warning: {e}")
# Continue anyway - validation ist optional
return advo_data
@staticmethod