31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
# pxy_routing/services/provider.py
|
|
from __future__ import annotations
|
|
from typing import Any, Dict, Tuple
|
|
|
|
from .factory import get_routing_provider
|
|
|
|
# --- Legacy classes kept for backward compatibility ---
|
|
class RoutingProvider:
|
|
def health(self) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
def isochrone(self, center: Tuple[float, float], minutes: int) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
class NullRoutingProvider(RoutingProvider):
|
|
def health(self) -> Dict[str, Any]:
|
|
return {"provider": "null", "ok": False, "reason": "Routing provider not configured"}
|
|
|
|
def isochrone(self, center: Tuple[float, float], minutes: int) -> Dict[str, Any]:
|
|
raise NotImplementedError("Routing provider not configured")
|
|
|
|
# --- Functional API kept for existing callers ---
|
|
def health() -> Dict[str, Any]:
|
|
return get_routing_provider().health()
|
|
|
|
def isochrone(center: Tuple[float, float], minutes: int) -> Dict[str, Any]:
|
|
return get_routing_provider().isochrone(center, minutes)
|
|
|
|
# Optional convenience instance some code may import as 'rp'
|
|
rp = get_routing_provider()
|