clean up base infra
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled

This commit is contained in:
harkon
2025-10-11 11:42:43 +01:00
parent b324ff09ef
commit f0f7674b8d
52 changed files with 663 additions and 5224 deletions

View File

@@ -3,7 +3,7 @@
import asyncio
import logging
from libs.events import EventPayload, NATSEventBus, create_event_bus
from libs.events import EventPayload, NATSEventBus
# Configure logging
logging.basicConfig(level=logging.INFO)
@@ -20,7 +20,7 @@ async def example_handler(topic: str, payload: EventPayload) -> None:
)
async def main():
async def main() -> None:
"""Main example function."""
# Method 1: Direct instantiation
nats_bus = NATSEventBus(
@@ -67,7 +67,11 @@ async def main():
# Publish an update event
update_payload = EventPayload(
data={"user_id": "user-1", "name": "Updated User 1", "email": "user1@example.com"},
data={
"user_id": "user-1",
"name": "Updated User 1",
"email": "user1@example.com",
},
actor="admin",
tenant_id="tenant-123",
)
@@ -86,7 +90,7 @@ async def main():
logger.info("NATS event bus stopped")
async def cluster_example():
async def cluster_example() -> None:
"""Example with NATS cluster configuration."""
# Connect to a NATS cluster
cluster_bus = NATSEventBus(
@@ -117,9 +121,9 @@ async def cluster_example():
await cluster_bus.stop()
async def error_handling_example():
async def error_handling_example() -> None:
"""Example showing error handling."""
async def failing_handler(topic: str, payload: EventPayload) -> None:
"""Handler that sometimes fails."""
if payload.data.get("should_fail"):
@@ -127,7 +131,7 @@ async def error_handling_example():
logger.info(f"Successfully processed event {payload.event_id}")
bus = NATSEventBus()
try:
await bus.start()
await bus.subscribe("test.events", failing_handler)
@@ -157,7 +161,7 @@ async def error_handling_example():
if __name__ == "__main__":
# Run the basic example
asyncio.run(main())
# Uncomment to run other examples:
# asyncio.run(cluster_example())
# asyncio.run(error_handling_example())