cmd/wasmcloudd: compress logs at rest
This commit is contained in:
parent
59dce00111
commit
fc46430065
|
@ -9,6 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-interpreter/wagon/wasm"
|
||||
"github.com/golang/snappy"
|
||||
shell "github.com/ipfs/go-ipfs-api"
|
||||
"github.com/rogpeppe/go-internal/txtar"
|
||||
"tulpa.dev/within/wasmcloud/cmd/internal"
|
||||
|
@ -213,7 +214,19 @@ func getLogs(w http.ResponseWriter, r *http.Request, u *User) {
|
|||
var result []resultLine
|
||||
|
||||
for _, elog := range elogs {
|
||||
arc := txtar.Parse(elog.Data)
|
||||
decompressed, err := snappy.Decode(nil, elog.Data)
|
||||
if err != nil {
|
||||
ln.Error(ctx, err)
|
||||
result = append(result, resultLine{
|
||||
ExecID: elog.RunID,
|
||||
Comment: "ERROR IN DECOMPRESSING LOG BUNDLE",
|
||||
Logs: map[string]string{
|
||||
"logs.txt": err.Error(),
|
||||
},
|
||||
})
|
||||
continue
|
||||
}
|
||||
arc := txtar.Parse(decompressed)
|
||||
logs := map[string]string{}
|
||||
|
||||
for _, file := range arc.Files {
|
||||
|
@ -261,10 +274,12 @@ func invokeHandlerSync(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
logData := txtar.Format(&resp.Logs)
|
||||
compressedLogs := snappy.Encode(nil, logData)
|
||||
|
||||
entry := ExecutionLog{
|
||||
HandlerID: hdlr.ID,
|
||||
RunID: resp.UUID,
|
||||
Data: logData,
|
||||
Data: compressedLogs,
|
||||
}
|
||||
|
||||
err = db.Save(&entry).Error
|
||||
|
@ -320,10 +335,11 @@ func invokeHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
data := txtar.Format(&resp.Logs)
|
||||
compressedLogs := snappy.Encode(nil, data)
|
||||
entry := ExecutionLog{
|
||||
HandlerID: hdlr.ID,
|
||||
RunID: resp.UUID,
|
||||
Data: data,
|
||||
Data: compressedLogs,
|
||||
}
|
||||
|
||||
err = db.Save(&entry).Error
|
||||
|
|
Loading…
Reference in New Issue