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