From d6674a3dd21d54fc75f5d343fb2dd2d3d6dd163f Mon Sep 17 00:00:00 2001 From: "Miguel (Hermes Agent)" Date: Sat, 1 Aug 2026 20:59:09 +0200 Subject: [PATCH] feat(adapter): http_timeout als konfigurierbarer Parameter in RocketChatREST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - RocketChatREST.__init__ akzeptiert http_timeout (default 30.0) - _request() akzeptiert per-call timeout override - Default-Verhalten unverändert (30s), aber überschreibbar - Ermöglicht Circuit-Breaker im PulseController, Timeout dynamisch anzupassen Production-Impact: none (backward-compatible, default unchanged) --- plugin/adapter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugin/adapter.py b/plugin/adapter.py index 63120b9..b125b81 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -266,20 +266,22 @@ def _sanitize_file_path_component(value: str) -> str: class RocketChatREST: - def __init__(self, base_url: str): + def __init__(self, base_url: str, http_timeout: float = 30.0): self.base_url = base_url.rstrip("/") + self.http_timeout = http_timeout self.auth_token: Optional[str] = None self.user_id: Optional[str] = None - def _request(self, method: str, endpoint: str, headers: Optional[dict] = None, data: Optional[dict] = None): + def _request(self, method: str, endpoint: str, headers: Optional[dict] = None, data: Optional[dict] = None, timeout: Optional[float] = None): url = f"{self.base_url}{endpoint}" req_headers = dict(headers) if headers else {} body = json.dumps(data).encode("utf-8") if data else None if body: req_headers["Content-Type"] = "application/json" req = urllib.request.Request(url, data=body, headers=req_headers, method=method) + _timeout = timeout if timeout is not None else self.http_timeout try: - with urllib.request.urlopen(req, timeout=30) as resp: + with urllib.request.urlopen(req, timeout=_timeout) as resp: return json.loads(resp.read().decode("utf-8")) except urllib.error.HTTPError as e: if e.code == 429: