23 lines
620 B
Python
23 lines
620 B
Python
# pxy_routing/services/factory.py
|
|
from __future__ import annotations
|
|
import os
|
|
from functools import lru_cache
|
|
|
|
from .crowfly_provider import CrowFlyRoutingProvider
|
|
from .ors_provider import ORSRoutingProvider
|
|
|
|
@lru_cache(maxsize=1)
|
|
def get_routing_provider():
|
|
"""
|
|
Select routing provider by env:
|
|
ROUTING_PROVIDER = ors | crowfly (default: crowfly)
|
|
"""
|
|
name = (os.getenv("ROUTING_PROVIDER") or "crowfly").strip().lower()
|
|
|
|
if name == "ors":
|
|
# ORS_* knobs are read inside ORSRoutingProvider
|
|
return ORSRoutingProvider()
|
|
|
|
# Fallback/default
|
|
return CrowFlyRoutingProvider()
|