mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-16 02:15:08 +00:00
fix(api): address review on the event-loop streams
- Per-user SSE cap uses per-connection leases in a sorted set instead of a shared INCR/DECR counter with a TTL. A stream that outlived the TTL could let the counter expire, then decrement another stream's slot or drive the count negative. Leases refresh while a stream sends frames and age out when a stream dies without cleanup. - Shielded cleanup is bounded per step: stream close and on_close in ClosingStreamingResponse, unsubscribe and close in AsyncTopic, lease release, and the replay-budget check, so a dead Redis connection can't hold a request or a graceful shutdown. - Artifact downloads send an ASCII filename plus an RFC 5987 filename* for non-ASCII names, build headers before opening the file, and close disk handles off the event loop. - Type hints and docstrings on the new helpers.
This commit is contained in:
1 parent
54b540ea42
commit
e889392eba
17 files changed
+911
-255
No files matched your search
@@ -19,7 +19,7 @@ from docsgpt.api.events.routes import (
|
||||
_normalize_last_event_id,
|
||||
)
|
||||
from docsgpt.events.keys import (
|
||||
connection_counter_key,
|
||||
connection_leases_key,
|
||||
stream_id_compare,
|
||||
stream_key,
|
||||
topic_name,
|
||||
@@ -39,8 +39,8 @@ class TestKeys:
|
||||
def test_topic_name(self):
|
||||
assert topic_name("alice") == "user:alice"
|
||||
|
||||
def test_connection_counter_key(self):
|
||||
assert connection_counter_key("alice") == "user:alice:sse_count"
|
||||
def test_connection_leases_key(self):
|
||||
assert connection_leases_key("alice") == "user:alice:sse_leases"
|
||||
|
||||
|
||||
# ── stream_id_compare ───────────────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user