video reaction 플러시 1분 간격
This commit is contained in:
1 parent
97379bebd4
commit
9f17786920
4 files changed
+528
-14
No files matched your search
@@ -6,10 +6,12 @@
|
||||
from jobs.tiktok import TikTokUploadJob
|
||||
"""
|
||||
|
||||
from jobs.reaction_flush import ReactionFlushJob
|
||||
from jobs.sns_upload import SnsUploadJob
|
||||
|
||||
JOBS = [
|
||||
SnsUploadJob(),
|
||||
ReactionFlushJob(),
|
||||
# InstagramUploadJob(),
|
||||
# TikTokUploadJob(),
|
||||
]
|
||||
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
VideoReaction Write-Behind 플러시 잡
|
||||
|
||||
1분마다 백엔드 내부 API를 호출하여 Redis dirty SET의 좋아요 토글을 MySQL에 반영합니다.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
import httpx
|
||||
|
||||
from config import settings
|
||||
from jobs.base import BaseJob
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ReactionFlushJob(BaseJob):
|
||||
name = "VideoReaction 플러시"
|
||||
|
||||
async def run(self) -> None:
|
||||
logger.info("[REACTION_FLUSH] 플러시 시작")
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.post(
|
||||
f"{settings.BACKEND_INTERNAL_URL}/internal/video/reactions/flush",
|
||||
headers={"X-Internal-Secret": settings.INTERNAL_SECRET_KEY},
|
||||
timeout=30.0,
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
result = response.json()
|
||||
logger.info(
|
||||
f"[REACTION_FLUSH] SUCCESS - "
|
||||
f"flushed: {result.get('flushed', 0)}, "
|
||||
f"adds: {result.get('adds', 0)}, "
|
||||
f"dels: {result.get('dels', 0)}"
|
||||
)
|
||||
|
||||
except httpx.HTTPStatusError as e:
|
||||
logger.error(
|
||||
f"[REACTION_FLUSH] HTTP 오류 - "
|
||||
f"status: {e.response.status_code}, body: {e.response.text}"
|
||||
)
|
||||
except httpx.RequestError as e:
|
||||
logger.error(f"[REACTION_FLUSH] 요청 오류 - error: {e}")
|
||||
except Exception as e:
|
||||
logger.error(f"[REACTION_FLUSH] EXCEPTION - error: {e}")
|
||||
Reference in new issue
Block a user