ЛР7: перенести минимум lab6 в приложение (API, worker, OTel)
- бизнес-API без изменений контракта; транспорт теперь HTTPS за mTLS-relay - retry задачи переопубликовывается через outbox (в lab6 задача после ошибки оставалась в queued навсегда); trace context сохраняется в outbox.headers, поэтому API -> broker -> worker остаётся одной трассой - структурные JSON-логи: trace_id/span_id в теле строки (SDK игнорирует formatter, поэтому добавлен JsonLoggingHandler) - закрыты дефекты lab6: закреплён uid datasource в dashboard, убрана зависимость от Valkey (сессии и rate limit - в PostgreSQL) - метрики/логи/трассы уходят в Collector по OTLP с клиентским сертификатом Co-Authored-By: O3 Agent Claude <noreply@ozon.ru>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
class ApiError(Exception):
|
||||
def __init__(self, status, code, message, headers=None):
|
||||
super().__init__(message)
|
||||
self.status, self.code, self.message, self.headers = status, code, message, headers or {}
|
||||
|
||||
|
||||
BASIC_CHALLENGE = {"WWW-Authenticate": 'Basic realm="messenger", charset="UTF-8"'}
|
||||
BEARER_CHALLENGE = {"WWW-Authenticate": 'Bearer realm="messenger"'}
|
||||
|
||||
|
||||
def bad_request(message="Некорректный запрос"):
|
||||
return ApiError(400, "invalid_request", message)
|
||||
|
||||
|
||||
def unauthorized(challenge):
|
||||
return ApiError(401, "unauthorized", "Требуется аутентификация", challenge)
|
||||
|
||||
|
||||
def not_found():
|
||||
return ApiError(404, "not_found", "Объект не найден")
|
||||
Reference in New Issue
Block a user