Move execution reporting into the HTTP adapter
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/scriptorium/internal/defaults"
|
||||
executionreport "gitea.maximumdirect.net/eric/scriptorium/internal/report"
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
@@ -121,13 +120,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
TransientRetries: req.TransientRetries,
|
||||
OperationTimeout: operationTimeout,
|
||||
}
|
||||
var collector *executionreport.Collector
|
||||
var collector *executionCollector
|
||||
if req.IncludeExecutionReport {
|
||||
collector = executionreport.NewCollector()
|
||||
collector = newExecutionCollector()
|
||||
mappedRequest.Observer = collector.Observe
|
||||
}
|
||||
res, err := h.runner.Run(r.Context(), mappedRequest)
|
||||
var execution *executionreport.Execution
|
||||
var execution *executionReport
|
||||
if collector != nil {
|
||||
execution = collector.Snapshot()
|
||||
}
|
||||
@@ -185,7 +184,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
writeLimitedJSON(w, http.StatusOK, resp, h.options.MaxResponseBytes)
|
||||
}
|
||||
|
||||
func writeRunFailure(w http.ResponseWriter, status int, code, message string, execution *executionreport.Execution, maxBytes int64) {
|
||||
func writeRunFailure(w http.ResponseWriter, status int, code, message string, execution *executionReport, maxBytes int64) {
|
||||
if execution == nil {
|
||||
writeError(w, status, code, message)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user