chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"net/http"
|
||||
|
||||
taskexecapp "inbox/internal/app/taskexec"
|
||||
"inbox/internal/base/httpx"
|
||||
"inbox/internal/domain/workflow"
|
||||
)
|
||||
|
||||
func (h *Handler) runtimeNextTaskExecution(w http.ResponseWriter, r *http.Request) {
|
||||
type request struct {
|
||||
RunnerID string `json:"runner_id"`
|
||||
}
|
||||
var req request
|
||||
if err := httpx.DecodeJSON(r, &req); err != nil {
|
||||
httpx.WriteError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
item, err := h.TaskExec.ClaimNext(r.Context(), r.PathValue("laneID"), req.RunnerID)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
return
|
||||
}
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusOK, map[string]any{"assignment": item})
|
||||
}
|
||||
|
||||
func (h *Handler) runtimeTaskExecutionComplete(w http.ResponseWriter, r *http.Request) {
|
||||
type request struct {
|
||||
Status string `json:"status"`
|
||||
ExitCode int `json:"exit_code"`
|
||||
ResultMarkdown string `json:"result_markdown"`
|
||||
ErrorMessage string `json:"error_message"`
|
||||
}
|
||||
var req request
|
||||
if err := httpx.DecodeJSON(r, &req); err != nil {
|
||||
httpx.WriteError(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
item, err := h.TaskExec.Complete(r.Context(), taskexecapp.Completion{
|
||||
RunID: r.PathValue("runID"),
|
||||
Status: workflow.RunStatus(req.Status),
|
||||
ExitCode: req.ExitCode,
|
||||
ResultMarkdown: req.ResultMarkdown,
|
||||
ErrorMessage: req.ErrorMessage,
|
||||
})
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
httpx.WriteJSON(w, http.StatusOK, item)
|
||||
}
|
||||
Reference in New Issue
Block a user