feat: add audited task review and linked manual retries
This commit is contained in:
@@ -77,6 +77,30 @@ func registerTasks(mux *http.ServeMux, s *service.Service) {
|
||||
}))
|
||||
mux.HandleFunc("POST /v1/tasks/{command}", wrap(func(r *http.Request, t auth.Token) (any, int, error) {
|
||||
command := r.PathValue("command")
|
||||
if strings.HasSuffix(command, ":review") {
|
||||
var in service.ReviewInput
|
||||
if err := decodeBody(r, &in); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
key, err := idempotencyKey(r)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
out, err := s.ReviewTask(r.Context(), t, core.ID(strings.TrimSuffix(command, ":review")), key, in)
|
||||
return out, 200, err
|
||||
}
|
||||
if strings.HasSuffix(command, ":retry") {
|
||||
var in service.ManualRetryInput
|
||||
if err := decodeBody(r, &in); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
key, err := idempotencyKey(r)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
out, err := s.RetryTask(r.Context(), t, core.ID(strings.TrimSuffix(command, ":retry")), key, in)
|
||||
return out, createdStatus(out.Deduplicated), err
|
||||
}
|
||||
if !strings.HasSuffix(command, ":cancel") {
|
||||
return nil, 0, fault.NotFound
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user