Fix bugs issues
This commit is contained in:
@@ -3,7 +3,7 @@ Event definitions for microservices communication
|
||||
- Simple class-based approach to avoid dataclass issues
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from typing import Dict, Any, Optional
|
||||
import uuid
|
||||
|
||||
@@ -14,8 +14,19 @@ class BaseEvent:
|
||||
self.data = data
|
||||
self.event_type = event_type
|
||||
self.event_id = str(uuid.uuid4())
|
||||
self.timestamp = datetime.utcnow()
|
||||
self.timestamp = datetime.now(timezone.utc)
|
||||
self.correlation_id = correlation_id
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]: # Add this method
|
||||
"""Converts the event object to a dictionary for JSON serialization."""
|
||||
return {
|
||||
"service_name": self.service_name,
|
||||
"data": self.data,
|
||||
"event_type": self.event_type,
|
||||
"event_id": self.event_id,
|
||||
"timestamp": self.timestamp.isoformat(), # Convert datetime to ISO 8601 string
|
||||
"correlation_id": self.correlation_id
|
||||
}
|
||||
|
||||
# Training Events
|
||||
class TrainingStartedEvent(BaseEvent):
|
||||
|
||||
Reference in New Issue
Block a user