fix
This commit is contained in:
parent
2ff6c22e0b
commit
f35115d2f2
@ -9,10 +9,17 @@ from app.storage import redis
|
|||||||
router = fastapi.APIRouter()
|
router = fastapi.APIRouter()
|
||||||
|
|
||||||
|
|
||||||
|
class Task(pydantic.BaseModel):
|
||||||
|
id: str
|
||||||
|
attempt: int
|
||||||
|
payload: dict
|
||||||
|
|
||||||
|
|
||||||
class Response(pydantic.BaseModel):
|
class Response(pydantic.BaseModel):
|
||||||
id: str
|
id: str
|
||||||
attempt: int
|
attempt: int
|
||||||
payload: dict
|
payload: dict
|
||||||
|
task: Task|None
|
||||||
|
|
||||||
|
|
||||||
@router.get('/api/v1/take', responses={404: {'description': 'Not found'}})
|
@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)
|
task = await tasks.take_task(queue)
|
||||||
if not task:
|
if not task:
|
||||||
raise fastapi.HTTPException(404)
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user