chunker ui redo
This commit is contained in:
@@ -173,6 +173,43 @@ class WorkerServicer(worker_pb2_grpc.WorkerServiceServicer):
|
||||
message="Job not found",
|
||||
)
|
||||
|
||||
def StreamChunkPipeline(self, request, context) -> Iterator[worker_pb2.ChunkPipelineEvent]:
|
||||
"""Stream chunk pipeline events for a job."""
|
||||
from core.events import poll_events
|
||||
|
||||
job_id = request.job_id
|
||||
logger.info(f"StreamChunkPipeline: {job_id}")
|
||||
|
||||
cursor = 0
|
||||
timeout = time.monotonic() + 600 # 10 min max
|
||||
|
||||
while context.is_active() and time.monotonic() < timeout:
|
||||
events, cursor = poll_events(job_id, cursor)
|
||||
|
||||
for data in events:
|
||||
event_type = data.pop("event", "")
|
||||
yield worker_pb2.ChunkPipelineEvent(
|
||||
job_id=job_id,
|
||||
event_type=event_type,
|
||||
sequence=data.get("sequence", 0),
|
||||
worker_id=data.get("worker_id", ""),
|
||||
state=data.get("state", ""),
|
||||
queue_size=data.get("queue_size", 0),
|
||||
elapsed=data.get("elapsed", 0.0),
|
||||
throughput_mbps=data.get("throughput_mbps", 0.0),
|
||||
total_chunks=data.get("total_chunks", 0),
|
||||
processed_chunks=data.get("processed_chunks", 0),
|
||||
failed_chunks=data.get("failed_chunks", 0),
|
||||
error=data.get("error", ""),
|
||||
processing_time=data.get("processing_time", 0.0),
|
||||
retries=data.get("retries", 0),
|
||||
)
|
||||
|
||||
if event_type in ("pipeline_complete", "pipeline_error"):
|
||||
return
|
||||
|
||||
time.sleep(0.05)
|
||||
|
||||
def GetWorkerStatus(self, request, context):
|
||||
"""Get worker health and capabilities."""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user