mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-16 05:55:09 +00:00
perf(api)!: cut per-request and per-tick event bus traffic
Session update events carry the new action as action_entry instead of the full log; access lines stay out of the log ring unless --debug. Job events build and redact their dict once, the progress interval matches the 0.5 s poll, and dashboard stats are serialized once.
This commit is contained in:
@@ -183,7 +183,9 @@ async def test_session_action_log() -> None:
|
||||
store.record_action(entry.session_id, {"action": "titles", "status": 200})
|
||||
store.record_action("missing", {"action": "titles", "status": 200})
|
||||
assert entry.summary()["actions"] == [{"action": "titles", "status": 200}]
|
||||
assert queue.get_nowait()["data"]["action"] == "update" and queue.empty()
|
||||
event = queue.get_nowait()["data"]
|
||||
assert event["action"] == "update" and queue.empty()
|
||||
assert event["action_entry"] == {"action": "titles", "status": 200} and "actions" not in event
|
||||
finally:
|
||||
bus.unsubscribe(queue)
|
||||
|
||||
|
||||
@@ -82,6 +82,29 @@ def test_to_dict_full_details_redacts_error_fields_and_parameters():
|
||||
assert d["parameters"]["credential"] == "***"
|
||||
|
||||
|
||||
def test_to_dict_redacts_again_only_when_an_error_field_changes(monkeypatch):
|
||||
from unshackle.core.api import download_manager
|
||||
|
||||
calls = []
|
||||
real = download_manager._redact_text
|
||||
monkeypatch.setattr(download_manager, "_redact_text", lambda text, params: calls.append(text) or real(text, params))
|
||||
job = DownloadJob(
|
||||
job_id="j1",
|
||||
status=JobStatus.FAILED,
|
||||
created_time=datetime(2026, 1, 1),
|
||||
service="EXAMPLE",
|
||||
title_id="t",
|
||||
parameters={"credential": "user:hunter2"},
|
||||
)
|
||||
job.error_message = "login failed for user:hunter2"
|
||||
job.to_dict(include_full_details=True)
|
||||
job.to_dict(include_full_details=True)
|
||||
assert len(calls) == 4
|
||||
job.error_message = "still failing for user:hunter2"
|
||||
assert "hunter2" not in job.to_dict(include_full_details=True)["error_message"]
|
||||
assert len(calls) == 8
|
||||
|
||||
|
||||
class _PastGate(Exception):
|
||||
"""Raised by the stubbed download manager to prove a request got past the gate."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user