29 lines
758 B
Python
29 lines
758 B
Python
"""
|
|
ThinkStorm Service Adapters Base Module
|
|
Defines interface contracts and health status checks.
|
|
"""
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Dict, Any, Optional, Tuple
|
|
from abc import ABC, abstractmethod
|
|
|
|
@dataclass
|
|
class ServiceHealth:
|
|
service_id: str
|
|
healthy: bool
|
|
endpoint: str
|
|
message: str
|
|
response_time_ms: int = 0
|
|
extra: Dict[str, Any] = None
|
|
|
|
class BaseServiceAdapter(ABC):
|
|
def __init__(self, service_id: str, endpoint: str, api_key: str = ""):
|
|
self.service_id = service_id
|
|
self.endpoint = endpoint.rstrip("/")
|
|
self.api_key = api_key
|
|
|
|
@abstractmethod
|
|
async def check_health(self) -> ServiceHealth:
|
|
"""Tests live connectivity and returns health status."""
|
|
pass
|