- Remove DistributedListSplitter and DistributedListCollector nodes - Remove /distributed/init_list_queue and /distributed/request_list_item endpoints - Clean up all references from prompt_transform, queue_orchestration, constants, and tests - Refactor and reorganize distributed modules for quality improvements
26 lines
808 B
Python
26 lines
808 B
Python
"""Shared endpoint policy helpers for distributed API routes."""
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Awaitable, Callable
|
|
|
|
from aiohttp import web
|
|
|
|
from ..utils.network import handle_api_error
|
|
from .request_guards import authorization_error_or_none
|
|
|
|
|
|
async def run_authorized_endpoint(
|
|
request: web.Request,
|
|
operation: Callable[[], Awaitable[web.StreamResponse]],
|
|
*,
|
|
unexpected_status: int = 500,
|
|
) -> web.StreamResponse:
|
|
"""Run endpoint operation with shared auth guard and fallback error mapping."""
|
|
auth_error = await authorization_error_or_none(request)
|
|
if auth_error is not None:
|
|
return auth_error
|
|
try:
|
|
return await operation()
|
|
except Exception as exc:
|
|
return await handle_api_error(request, exc, unexpected_status)
|