Add new infra architecture
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
# Procurement Service Dockerfile
|
||||
# Stage 1: Copy shared libraries
|
||||
FROM python:3.11-slim AS shared
|
||||
FROM localhost:5000/python_3.11-slim AS shared
|
||||
WORKDIR /shared
|
||||
COPY shared/ /shared/
|
||||
|
||||
# Stage 2: Main service
|
||||
FROM python:3.11-slim
|
||||
FROM localhost:5000/python_3.11-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
@@ -156,21 +156,14 @@ class DeliveryTrackingService:
|
||||
|
||||
async def _check_all_tenants(self):
|
||||
"""
|
||||
Check deliveries for all active tenants (with leader election).
|
||||
Check deliveries for all active tenants.
|
||||
|
||||
Only one pod executes this - others skip if not leader.
|
||||
This method is only called by the leader pod (via APScheduler).
|
||||
Leader election is handled at the scheduler level, not here.
|
||||
"""
|
||||
# Try to acquire leader lock
|
||||
if not await self._try_acquire_leader_lock():
|
||||
logger.debug(
|
||||
"Skipping delivery check - not leader",
|
||||
instance_id=self.instance_id
|
||||
)
|
||||
return
|
||||
logger.info("Starting delivery checks", instance_id=self.instance_id)
|
||||
|
||||
try:
|
||||
logger.info("Starting delivery checks (as leader)", instance_id=self.instance_id)
|
||||
|
||||
# Get all active tenants from database
|
||||
tenants = await self._get_active_tenants()
|
||||
|
||||
@@ -194,24 +187,8 @@ class DeliveryTrackingService:
|
||||
total_alerts=total_alerts
|
||||
)
|
||||
|
||||
finally:
|
||||
await self._release_leader_lock()
|
||||
|
||||
async def _try_acquire_leader_lock(self) -> bool:
|
||||
"""
|
||||
Try to acquire leader lock for delivery tracking.
|
||||
|
||||
Uses Redis to ensure only one pod runs checks.
|
||||
Returns True if acquired, False if another pod is leader.
|
||||
"""
|
||||
# This simplified version doesn't implement leader election
|
||||
# In a real implementation, you'd use Redis or database locks
|
||||
logger.info("Delivery tracking check running", instance_id=self.instance_id)
|
||||
return True
|
||||
|
||||
async def _release_leader_lock(self):
|
||||
"""Release leader lock"""
|
||||
logger.debug("Delivery tracking check completed", instance_id=self.instance_id)
|
||||
except Exception as e:
|
||||
logger.error("Delivery checks failed", error=str(e), exc_info=True)
|
||||
|
||||
async def _get_active_tenants(self) -> List[UUID]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user