MCPcopy Create free account
hub / github.com/compozy/agh / EnqueueTaskRun

Method EnqueueTaskRun

internal/api/core/tasks.go:1325–1366  ·  view source on GitHub ↗

EnqueueTaskRun creates one new queue-first run for the supplied task.

(c *gin.Context)

Source from the content-addressed store, hash-verified

1323
1324// EnqueueTaskRun creates one new queue-first run for the supplied task.
1325func (h *BaseHandlers) EnqueueTaskRun(c *gin.Context) {
1326 manager, ok := h.requireTaskManager(c)
1327 if !ok {
1328 return
1329 }
1330
1331 taskID, err := requiredPathID(c.Param("id"), "task id")
1332 if err != nil {
1333 h.respondError(c, StatusForTaskError(err), err)
1334 return
1335 }
1336
1337 var req contract.EnqueueTaskRunRequest
1338 if err := decodeOptionalJSON(c, &req); err != nil {
1339 h.respondError(
1340 c,
1341 http.StatusBadRequest,
1342 NewTaskValidationError(fmt.Errorf("%s: decode enqueue run request: %w", h.transportName(), err)),
1343 )
1344 return
1345 }
1346
1347 actor, err := h.taskActorContext(c, taskActionEnqueueRun)
1348 if err != nil {
1349 h.respondError(c, StatusForTaskError(err), err)
1350 return
1351 }
1352
1353 spec, err := enqueueTaskRunFromRequest(taskID, req)
1354 if err != nil {
1355 h.respondError(c, StatusForTaskError(err), err)
1356 return
1357 }
1358
1359 run, err := manager.EnqueueRun(c.Request.Context(), spec, actor)
1360 if err != nil {
1361 h.respondError(c, StatusForTaskError(err), err)
1362 return
1363 }
1364
1365 c.JSON(http.StatusCreated, contract.TaskRunResponse{Run: TaskRunPayloadFromRun(run)})
1366}
1367
1368// FanOutTaskRuns creates designated sibling runs for one task.
1369func (h *BaseHandlers) FanOutTaskRuns(c *gin.Context) {

Callers

nothing calls this directly

Calls 11

requireTaskManagerMethod · 0.95
respondErrorMethod · 0.95
transportNameMethod · 0.95
taskActorContextMethod · 0.95
requiredPathIDFunction · 0.85
StatusForTaskErrorFunction · 0.85
decodeOptionalJSONFunction · 0.85
NewTaskValidationErrorFunction · 0.85
TaskRunPayloadFromRunFunction · 0.85
EnqueueRunMethod · 0.65

Tested by

no test coverage detected