From 0cf57bfaca9786f48703aedd7fcca5c30022f090 Mon Sep 17 00:00:00 2001 From: marsal Date: Fri, 10 Jul 2026 12:08:40 +0800 Subject: [PATCH] feat(config): add event publisher settings --- channel-service/app/config.py | 6 ++++++ channel-service/app/repositories/event_store.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/channel-service/app/config.py b/channel-service/app/config.py index 6eb59c8..ab44c34 100644 --- a/channel-service/app/config.py +++ b/channel-service/app/config.py @@ -12,5 +12,11 @@ class Settings(BaseSettings): heartbeat_interval_seconds: int = int(os.getenv("HEARTBEAT_INTERVAL_SECONDS", "30")) pywechat_mock_mode: bool = os.getenv("PYWECHAT_MOCK_MODE", "true").lower() == "true" + event_store_path: str = os.getenv("EVENT_STORE_PATH", "./data/events.db") + max_retry: int = int(os.getenv("MAX_RETRY", "5")) + base_retry_delay_seconds: int = int(os.getenv("BASE_RETRY_DELAY_SECONDS", "5")) + event_retention_days: int = int(os.getenv("EVENT_RETENTION_DAYS", "10")) + event_publish_interval_seconds: float = float(os.getenv("EVENT_PUBLISH_INTERVAL_SECONDS", "5")) + settings = Settings() diff --git a/channel-service/app/repositories/event_store.py b/channel-service/app/repositories/event_store.py index 6eac066..0ce5af2 100644 --- a/channel-service/app/repositories/event_store.py +++ b/channel-service/app/repositories/event_store.py @@ -1,17 +1,20 @@ from __future__ import annotations import json +import os import sqlite3 import threading from datetime import datetime, timedelta, timezone from typing import Optional +from app.config import settings from app.models.event import EventStatus, EventType, OutboundEvent class EventStore: def __init__(self, db_path: str): self.db_path = db_path + os.makedirs(os.path.dirname(os.path.abspath(db_path)), exist_ok=True) self._local = threading.local() self._init_db() @@ -136,3 +139,6 @@ class EventStore: (threshold,), ) return cursor.rowcount + + +event_store = EventStore(settings.event_store_path)