mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-13 17:52:38 +02:00
Add typed event payload modules for the streaming service.
This commit is contained in:
parent
a9bf7ab7d2
commit
5510c6c314
11 changed files with 571 additions and 0 deletions
23
surfsense_backend/app/services/streaming/events/error.py
Normal file
23
surfsense_backend/app/services/streaming/events/error.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"""Single terminal error path the orchestrator must route through."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from ..emitter import Emitter, attach_emitted_by
|
||||
from ..envelope import format_sse
|
||||
|
||||
|
||||
def format_error(
|
||||
error_text: str,
|
||||
*,
|
||||
error_code: str | None = None,
|
||||
extra: dict[str, Any] | None = None,
|
||||
emitter: Emitter | None = None,
|
||||
) -> str:
|
||||
payload: dict[str, Any] = {"type": "error", "errorText": error_text}
|
||||
if error_code:
|
||||
payload["errorCode"] = error_code
|
||||
if extra:
|
||||
payload.update(extra)
|
||||
return format_sse(attach_emitted_by(payload, emitter))
|
||||
Loading…
Add table
Add a link
Reference in a new issue