feat(adapter): http_timeout als konfigurierbarer Parameter in RocketChatREST

- 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)
This commit is contained in:
Miguel (Hermes Agent)
2026-08-01 20:59:09 +02:00
committed by Bernd (Hermes)
parent 8fba9a4a39
commit d6674a3dd2
+5 -3
View File
@@ -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: