Rebuild AgentRunSupervisor on go.gearno.de/kit/worker
The supervisor was a hand-rolled polling, semaphore, and wait-group loop predating the project's adoption of the shared worker kit. Two sibling workers in pkg/probo already use the kit, and go-worker.md documents it as the project convention. This commit introduces agentRunHandler, which implements worker.Handler[coredata.AgentRun] and worker.StaleRecoverer, and reduces AgentRunSupervisor to a thin wrapper that owns the handler plus a worker.Worker and bridges ctx cancellation into a handler- level shutdown broadcast via context.AfterFunc. The agent stop channel is now closed by a per-Process forwarder goroutine when the broadcast fires, so in-flight runs checkpoint at the next turn boundary and drain through wg.Wait before Run returns. The stop_requested column, struct field, supporting SQL, and the LoadRunningStopRequestedIDs function are removed end-to-end. None of it was ever wired to an external surface; it existed purely to let the supervisor find runs the operator wanted to halt. With the kit handling the polling cadence and the AfterFunc bridging shutdown, per-row flagging is dead weight. The supervisor's public API (NewAgentRunSupervisor, Run, the With* option helpers, and the error sentinels) stays intact so probod.go needs no change. The integration test now triggers stop by cancelling the supervisor context, which is the actual production path through SIGTERM rather than a synthetic DB flag. Prometheus counters and OTel spans labelled worker="agent-run-supervisor" come for free. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -22,7 +22,6 @@ CREATE TABLE agent_runs (
|
||||
input_messages JSONB NOT NULL,
|
||||
result JSONB,
|
||||
error_message TEXT,
|
||||
stop_requested BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
started_at TIMESTAMPTZ,
|
||||
lease_owner TEXT,
|
||||
lease_expires_at TIMESTAMPTZ,
|
||||
|
||||
Reference in New Issue
Block a user