mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-08-26 17:31:37 +00:00
navi-offroute: drop unused connection cache from HPAManifest (cleanup)
The connection cache field (_conns) and get_connection() method were shipped in PR #53 "ready for future use" but never consumed by the v1 dispatch path: astar_hpa_multimode opens its own sqlite connection per call (astar.py:752) and changing that signature was out of scope. Per self-review of PR #53: shipping dead code in a PR is wrong even when the rationale is "future PRs will use it." Removing it here keeps the manifest module focused on lookup; whoever needs the cache later can add it alongside the use site. - Drop _conns field, get_connection() method. - Drop sqlite3 + Dict imports (no longer referenced). - Drop test_get_connection_caches_per_path. 23 deletions, 2 insertions. No production behaviour change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
711e9ba1df
commit
d6f4db34ff
2 changed files with 2 additions and 25 deletions
|
|
@ -10,9 +10,8 @@ neither env var set -> HPA disabled (same as today).
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
import sqlite3
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Dict, List, Optional
|
||||
from typing import List, Optional
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -43,10 +42,8 @@ class TileDBEntry:
|
|||
|
||||
@dataclass
|
||||
class HPAManifest:
|
||||
"""Registry of regional tile DBs + lazy per-path sqlite connection cache.
|
||||
The cache is process-local mutable state; entries are immutable after load."""
|
||||
"""Registry of regional tile DBs. Immutable after load."""
|
||||
entries: List[TileDBEntry] = field(default_factory=list)
|
||||
_conns: Dict[str, sqlite3.Connection] = field(default_factory=dict)
|
||||
|
||||
def enabled(self) -> bool:
|
||||
return len(self.entries) > 0
|
||||
|
|
@ -73,17 +70,6 @@ class HPAManifest:
|
|||
return self.dbs_for_chunks(min(cx0, cx1), max(cx0, cx1),
|
||||
min(cy0, cy1), max(cy0, cy1))
|
||||
|
||||
def get_connection(self, abs_path: str) -> sqlite3.Connection:
|
||||
"""Read-only sqlite connection cached for the life of the process. v1
|
||||
dispatch (astar_hpa_multimode) opens its own connection per call and does
|
||||
not yet use this cache; multi-region UNION + admin endpoints will."""
|
||||
conn = self._conns.get(abs_path)
|
||||
if conn is None:
|
||||
conn = sqlite3.connect(f"file:{abs_path}?mode=ro", uri=True)
|
||||
self._conns[abs_path] = conn
|
||||
return conn
|
||||
|
||||
|
||||
# ── loaders ──────────────────────────────────────────────────────────────────
|
||||
|
||||
def _load_from_dir(dir_path: str) -> HPAManifest:
|
||||
|
|
|
|||
|
|
@ -106,12 +106,3 @@ def test_load_env_disabled_paths(tmp_path, monkeypatch):
|
|||
# neither var set -> empty
|
||||
monkeypatch.delenv(hm.ENV_LEGACY, raising=False)
|
||||
assert not hm.load().enabled()
|
||||
|
||||
|
||||
def test_get_connection_caches_per_path(tmp_path):
|
||||
import sqlite3
|
||||
p = _touch(str(tmp_path), "x.db")
|
||||
with sqlite3.connect(p) as c:
|
||||
c.execute("CREATE TABLE t (x INTEGER)")
|
||||
m = hm.HPAManifest(entries=[hm.TileDBEntry("x", p, None)])
|
||||
assert m.get_connection(p) is m.get_connection(p)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue