Coverage for src / lexigram / contracts / infra / resources.py: 0%
16 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
1"""Resource-related protocols for cross-package boundaries.
3This module defines interfaces for resource managers (e.g. connection pools)
4that other packages may interact with without depending on concrete
5implementations from lexigram or lexigram-admin.
6"""
8from __future__ import annotations
10from typing import Any, Protocol, runtime_checkable
13@runtime_checkable
14class PoolStatsProtocol(Protocol):
15 """Snapshot of pool statistics."""
17 pool_utilization: float
18 last_health_check: Any
19 total_connections: int
20 active_connections: int
21 idle_connections: int
22 created_connections: int
23 destroyed_connections: int
26@runtime_checkable
27class PoolProtocol(Protocol):
28 """Protocol for an individual connection pool."""
30 def get_stats(self) -> PoolStatsProtocol: ...
32 async def close(self) -> None: ...
35@runtime_checkable
36class PoolManagerProtocol(Protocol):
37 """Manager that tracks pools by name."""
39 def get_stats(self) -> dict[str, PoolStatsProtocol]: ...
41 async def get_pool(self, name: str) -> PoolProtocol: ...
44__all__ = ["PoolManagerProtocol", "PoolProtocol", "PoolStatsProtocol"]