forked from mtusi2026/mtusi2026lab5
feat: ЛР5 - асинхронная обработка вложений, RabbitMQ и transactional outbox
This commit is contained in:
+21
-7
@@ -5,6 +5,8 @@ import re
|
||||
from enum import Enum
|
||||
from uuid import UUID
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||
|
||||
|
||||
@@ -137,12 +139,12 @@ class ChatPageResponse(BaseModel):
|
||||
class VariantResponse(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
name: str
|
||||
content_type: str
|
||||
size_bytes: int
|
||||
width: int
|
||||
height: int
|
||||
sha256: str
|
||||
name: Literal["thumbnail", "crop", "optimized"]
|
||||
content_type: Literal["image/jpeg", "image/png", "image/webp"]
|
||||
size_bytes: int = Field(ge=1)
|
||||
width: int = Field(ge=1)
|
||||
height: int = Field(ge=1)
|
||||
sha256: str = Field(pattern=r"^[a-f0-9]{64}$")
|
||||
|
||||
|
||||
class AttachmentResponse(BaseModel):
|
||||
@@ -155,13 +157,25 @@ class AttachmentResponse(BaseModel):
|
||||
content_type: str
|
||||
size_bytes: int
|
||||
sha256: str
|
||||
status: str = "ready"
|
||||
status: Literal["queued", "processing", "ready", "failed"] = "queued"
|
||||
variants: list[VariantResponse] = Field(default_factory=list)
|
||||
error_code: str | None = None
|
||||
created_at: str
|
||||
updated_at: str
|
||||
|
||||
|
||||
class AttachmentJobMessage(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
schema_version: Literal[1] = 1
|
||||
job_id: str
|
||||
type: Literal["attachment.process.v1"] = "attachment.process.v1"
|
||||
attachment_id: str
|
||||
pipeline_version: int = 1
|
||||
attempt: int = 1
|
||||
created_at: str
|
||||
|
||||
|
||||
class CreateMessageRequest(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid", strict=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user