Refactor API Docs CI workflow to correct ESLint command syntax and enhance Python formatting in CI pipelines; update progress tracking documentation
Some checks failed
API Docs (Node.js Express) / test (16) (push) Failing after 5m29s
API Docs (Node.js Express) / test (18) (push) Failing after 5m25s
API Docs (Node.js Express) / test (20) (push) Failing after 1m4s
API Docs (Node.js Express) / build (push) Has been skipped
API Docs (Node.js Express) / security (push) Has been skipped
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 4m52s
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 5m1s
LabFusion CI/CD Pipeline / api-docs (push) Failing after 5m12s
LabFusion CI/CD Pipeline / frontend (push) Failing after 6m39s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
LabFusion CI/CD Pipeline / security-scan (push) Has been skipped
Docker Build and Push / build-and-push (push) Failing after 34s
Docker Build and Push / security-scan (push) Has been skipped
Integration Tests / integration-tests (push) Failing after 1m33s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 35s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 5m20s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 5m27s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 5m50s
Docker Build and Push / deploy-staging (push) Has been skipped
Service Adapters (Python FastAPI) / build (push) Has been skipped
Service Adapters (Python FastAPI) / security (push) Has been skipped
Docker Build and Push / deploy-production (push) Has been skipped
Some checks failed
API Docs (Node.js Express) / test (16) (push) Failing after 5m29s
API Docs (Node.js Express) / test (18) (push) Failing after 5m25s
API Docs (Node.js Express) / test (20) (push) Failing after 1m4s
API Docs (Node.js Express) / build (push) Has been skipped
API Docs (Node.js Express) / security (push) Has been skipped
LabFusion CI/CD Pipeline / api-gateway (push) Failing after 4m52s
LabFusion CI/CD Pipeline / service-adapters (push) Failing after 5m1s
LabFusion CI/CD Pipeline / api-docs (push) Failing after 5m12s
LabFusion CI/CD Pipeline / frontend (push) Failing after 6m39s
LabFusion CI/CD Pipeline / integration-tests (push) Has been skipped
LabFusion CI/CD Pipeline / security-scan (push) Has been skipped
Docker Build and Push / build-and-push (push) Failing after 34s
Docker Build and Push / security-scan (push) Has been skipped
Integration Tests / integration-tests (push) Failing after 1m33s
Integration Tests / performance-tests (push) Has been skipped
Service Adapters (Python FastAPI) / test (3.1) (push) Failing after 35s
Service Adapters (Python FastAPI) / test (3.11) (push) Failing after 5m20s
Service Adapters (Python FastAPI) / test (3.12) (push) Failing after 5m27s
Service Adapters (Python FastAPI) / test (3.9) (push) Failing after 5m50s
Docker Build and Push / deploy-staging (push) Has been skipped
Service Adapters (Python FastAPI) / build (push) Has been skipped
Service Adapters (Python FastAPI) / security (push) Has been skipped
Docker Build and Push / deploy-production (push) Has been skipped
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
from fastapi import APIRouter, HTTPException, Query, BackgroundTasks
|
||||
from models.schemas import EventData, EventResponse, EventsResponse, Event
|
||||
from services.redis_client import redis_client
|
||||
from datetime import datetime
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException, Query
|
||||
|
||||
from models.schemas import Event, EventData, EventResponse, EventsResponse
|
||||
from services.redis_client import redis_client
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/publish-event",
|
||||
response_model=EventResponse,
|
||||
summary="Publish Event",
|
||||
description="Publish an event to the Redis message bus",
|
||||
responses={
|
||||
200: {"description": "Event published successfully"},
|
||||
500: {"description": "Failed to publish event"}
|
||||
},
|
||||
tags=["Events"])
|
||||
|
||||
@router.post(
|
||||
"/publish-event",
|
||||
response_model=EventResponse,
|
||||
summary="Publish Event",
|
||||
description="Publish an event to the Redis message bus",
|
||||
responses={
|
||||
200: {"description": "Event published successfully"},
|
||||
500: {"description": "Failed to publish event"},
|
||||
},
|
||||
tags=["Events"],
|
||||
)
|
||||
async def publish_event(event_data: EventData, background_tasks: BackgroundTasks):
|
||||
"""Publish an event to the Redis message bus for consumption by other services"""
|
||||
try:
|
||||
@@ -22,29 +27,33 @@ async def publish_event(event_data: EventData, background_tasks: BackgroundTasks
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"service": event_data.service,
|
||||
"event_type": event_data.event_type,
|
||||
"metadata": json.dumps(event_data.metadata)
|
||||
"metadata": json.dumps(event_data.metadata),
|
||||
}
|
||||
|
||||
|
||||
# Publish to Redis
|
||||
redis_client.lpush("events", json.dumps(event))
|
||||
|
||||
return EventResponse(
|
||||
status="published",
|
||||
event=event
|
||||
)
|
||||
|
||||
return EventResponse(status="published", event=event)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@router.get("/events",
|
||||
response_model=EventsResponse,
|
||||
summary="Get Events",
|
||||
description="Retrieve recent events from the message bus",
|
||||
responses={
|
||||
200: {"description": "Successfully retrieved events"},
|
||||
500: {"description": "Failed to retrieve events"}
|
||||
},
|
||||
tags=["Events"])
|
||||
async def get_events(limit: int = Query(100, ge=1, le=1000, description="Maximum number of events to retrieve")):
|
||||
|
||||
@router.get(
|
||||
"/events",
|
||||
response_model=EventsResponse,
|
||||
summary="Get Events",
|
||||
description="Retrieve recent events from the message bus",
|
||||
responses={
|
||||
200: {"description": "Successfully retrieved events"},
|
||||
500: {"description": "Failed to retrieve events"},
|
||||
},
|
||||
tags=["Events"],
|
||||
)
|
||||
async def get_events(
|
||||
limit: int = Query(
|
||||
100, ge=1, le=1000, description="Maximum number of events to retrieve"
|
||||
)
|
||||
):
|
||||
"""Get recent events from the Redis message bus"""
|
||||
try:
|
||||
events = redis_client.lrange("events", 0, limit - 1)
|
||||
@@ -55,7 +64,7 @@ async def get_events(limit: int = Query(100, ge=1, le=1000, description="Maximum
|
||||
parsed_events.append(Event(**event_data))
|
||||
except json.JSONDecodeError:
|
||||
continue
|
||||
|
||||
|
||||
return EventsResponse(events=parsed_events)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
Reference in New Issue
Block a user