master #15

Merged
emmatveev merged 2 commits from master into dev 2024-11-27 02:08:36 +03:00
Showing only changes of commit f35115d2f2 - Show all commits

View File

@ -9,10 +9,17 @@ from app.storage import redis
router = fastapi.APIRouter()
class Task(pydantic.BaseModel):
id: str
attempt: int
payload: dict
class Response(pydantic.BaseModel):
id: str
attempt: int
payload: dict
task: Task|None
@router.get('/api/v1/take', responses={404: {'description': 'Not found'}})
@ -20,4 +27,4 @@ async def execute(queue: typing.Annotated[str, fastapi.Header()]) -> Response:
task = await tasks.take_task(queue)
if not task:
raise fastapi.HTTPException(404)
return Response(id=str(task._id), attempt=task.attempts, payload=task.payload)
return Response(id=str(task._id), attempt=task.attempts, payload=task.payload, task=Task(id=str(task._id), attempt=task.attempts, payload=task.payload))