28 lines
539 B
Python
Executable File
28 lines
539 B
Python
Executable File
# app/jobs/progress.py
|
|
from typing import Dict
|
|
from api.routers.ws.manager import manager
|
|
|
|
# state job (in-memory dulu)
|
|
job_state: Dict[str, dict] = {}
|
|
|
|
|
|
async def report_progress(
|
|
job_id: str,
|
|
step: str,
|
|
progress: int,
|
|
message: str
|
|
):
|
|
"""
|
|
Fungsi tunggal untuk update & broadcast progress job
|
|
"""
|
|
|
|
job_state[job_id] = {
|
|
"job_id": job_id,
|
|
"step": step,
|
|
"progress": progress,
|
|
"message": message,
|
|
}
|
|
|
|
# push ke websocket
|
|
await manager.send(job_id, job_state[job_id])
|