From bef9038b56266cf200ca96b0adb1135548826447 Mon Sep 17 00:00:00 2001 From: Sam Welborn Date: Mon, 13 Jul 2026 12:08:48 -0400 Subject: [PATCH] add idle timeout option we add this so that we can control the timeout behavior from the orchestrator (`lclstream_api`) --- src/fastcache_api/models.py | 2 ++ src/fastcache_api/service.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/fastcache_api/models.py b/src/fastcache_api/models.py index 40a3e52..64788f3 100644 --- a/src/fastcache_api/models.py +++ b/src/fastcache_api/models.py @@ -58,6 +58,8 @@ class CacheRequest(BaseModel): requested_by: str # Absolute path the orchestrator dictates for this cache's log. log_path: Path + # Override for CacheConfig.timeout (fastcache's idle-receive timeout, ms). + idle_timeout_ms: int | None = None class CachePublic(BaseModel): diff --git a/src/fastcache_api/service.py b/src/fastcache_api/service.py index 74d3b31..10dfea1 100644 --- a/src/fastcache_api/service.py +++ b/src/fastcache_api/service.py @@ -74,10 +74,16 @@ async def create_cache(session: AsyncSession, req: CacheRequest) -> CacheCreatio except RuntimeError as exc: raise CachePortsExhausted(str(exc)) from exc + timeout = ( + req.idle_timeout_ms + if req.idle_timeout_ms is not None + else CacheConfig.model_fields["timeout"].default + ) config = CacheConfig( hostname=hostname, pull_uri=f"tcp://{hostname}:{pull_port}", push_uri=f"tcp://{hostname}:{push_port}", + timeout=timeout, ) cache_id = uuid4()