Implement iterative FTP scan and skip logic with processed file cache

- Add iterative directory scanning to prevent infinite recursion - Cache
processed files in memory to avoid redundant database lookups - Skip
already processed files using cache and database fallback - Add tests
for skip logic and iterative scan behavior - Change logging for MongoDB
connection and file storage to debug level - Clean up FastAPI app and
remove redundant docstrings
This commit is contained in:
rafaeldpsilva
2025-09-12 13:43:21 +01:00
parent a703240b27
commit aa07347604
8 changed files with 906 additions and 136 deletions

View File

@@ -4,7 +4,7 @@ services:
# Database Services
mongodb:
image: mongo:5.0
container_name: energy-mongodb
container_name: mongodb
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: admin
@@ -19,7 +19,7 @@ services:
redis:
image: redis:7-alpine
container_name: energy-redis
container_name: redis
restart: unless-stopped
ports:
- "6379:6379"
@@ -33,7 +33,7 @@ services:
build:
context: ./api-gateway
dockerfile: Dockerfile
container_name: energy-api-gateway
container_name: api-gateway
restart: unless-stopped
ports:
- "8000:8000"
@@ -51,7 +51,7 @@ services:
depends_on:
- mongodb
- redis
- token-service
# - token-service
- sensor-service
- data-ingestion-service
# - battery-service
@@ -60,28 +60,28 @@ services:
- energy-network
# Token Management Service
token-service:
build:
context: ./token-service
dockerfile: Dockerfile
container_name: energy-token-service
restart: unless-stopped
ports:
- "8001:8001"
environment:
- MONGO_URL=mongodb://admin:password123@localhost:27017/energy_dashboard_tokens?authSource=admin
- JWT_SECRET_KEY=your-super-secret-jwt-key-change-in-production
depends_on:
- mongodb
networks:
- energy-network
# token-service:
# build:
# context: ./token-service
# dockerfile: Dockerfile
# container_name: token-service
# restart: unless-stopped
# ports:
# - "8001:8001"
# environment:
# - MONGO_URL=mongodb://admin:password123@localhost:27017/energy_dashboard_tokens?authSource=admin
# - JWT_SECRET_KEY=your-super-secret-jwt-key-change-in-production
# depends_on:
# - mongodb
# networks:
# - energy-network
# Battery Management Service
# battery-service:
# build:
# context: ./battery-service
# dockerfile: Dockerfile
# container_name: energy-battery-service
# container_name: battery-service
# restart: unless-stopped
# ports:
# - "8002:8002"
@@ -99,7 +99,7 @@ services:
# build:
# context: ./demand-response-service
# dockerfile: Dockerfile
# container_name: energy-demand-response-service
# container_name: demand-response-service
# restart: unless-stopped
# ports:
# - "8003:8003"
@@ -118,7 +118,7 @@ services:
# build:
# context: ./p2p-trading-service
# dockerfile: Dockerfile
# container_name: energy-p2p-trading-service
# container_name: p2p-trading-service
# restart: unless-stopped
# ports:
# - "8004:8004"
@@ -136,7 +136,7 @@ services:
# build:
# context: ./forecasting-service
# dockerfile: Dockerfile
# container_name: energy-forecasting-service
# container_name: forecasting-service
# restart: unless-stopped
# ports:
# - "8005:8005"
@@ -154,7 +154,7 @@ services:
# build:
# context: ./iot-control-service
# dockerfile: Dockerfile
# container_name: energy-iot-control-service
# container_name: iot-control-service
# restart: unless-stopped
# ports:
# - "8006:8006"
@@ -174,7 +174,7 @@ services:
build:
context: ./data-ingestion-service
dockerfile: Dockerfile
container_name: energy-data-ingestion-service
container_name: data-ingestion-service
restart: unless-stopped
ports:
- "8008:8008"
@@ -183,8 +183,7 @@ services:
- FTP_SA4CPS_HOST=ftp.sa4cps.pt
- FTP_SA4CPS_PORT=21
- FTP_SA4CPS_USERNAME=curvascarga@sa4cps.pt
- FTP_SA4CPS_PASSWORD=n$WFtz9+bleN
- FTP_SA4CPS_REMOTE_PATH=/
- FTP_SA4CPS_REMOTE_PATH=/SLGs/
- FTP_CHECK_INTERVAL=21600
depends_on:
- mongodb
@@ -196,7 +195,7 @@ services:
build:
context: ./sensor-service
dockerfile: Dockerfile
container_name: energy-sensor-service
container_name: sensor-service
restart: unless-stopped
ports:
- "8007:8007"
@@ -213,7 +212,7 @@ services:
# Monitoring and Management
nginx:
image: nginx:alpine
container_name: energy-nginx
container_name: nginx
restart: unless-stopped
ports:
- "80:80"