Skip to content

Commit f2c831e

Browse files
committed
update wasm executor
I'm not currently able to build this myself but I did at some point
1 parent ecf8260 commit f2c831e

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

executor/wasm_executor.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import (
1111
"strings"
1212
"sync"
1313

14-
"github.com/bytecodealliance/wasmtime-go/v35"
14+
"github.com/bytecodealliance/wasmtime-go/v37"
1515
"github.com/nats-io/nats.go"
16+
log "github.com/sirupsen/logrus"
17+
1618
msgplugins "github.com/numkem/msgscript/plugins"
17-
scriptLib "github.com/numkem/msgscript/script"
19+
"github.com/numkem/msgscript/script"
1820
msgstore "github.com/numkem/msgscript/store"
19-
log "github.com/sirupsen/logrus"
2021
)
2122

2223
type WasmExecutor struct {
@@ -52,32 +53,24 @@ func (we *WasmExecutor) HandleMessage(ctx context.Context, msg *Message, rf Repl
5253
errs := make(chan error, len(scripts))
5354
var wg sync.WaitGroup
5455
r := NewReply()
55-
for path, content := range scripts {
56+
for path, scr := range scripts {
5657
wg.Add(1)
5758

58-
ss := strings.Split(path, "/")
59-
name := ss[len(ss)-1]
6059
fields := log.Fields{
61-
"subject": msg.Subject,
62-
"path": name,
60+
"subject": scr.Subject,
61+
"path": path,
6362
"executor": "wasm",
6463
}
6564

66-
go func(content []byte) {
65+
go func(scr *script.Script) {
6766
defer wg.Done()
6867

69-
script, err := scriptLib.ReadString(string(content))
70-
if err != nil {
71-
errs <- fmt.Errorf("failed to read script: %w", err)
72-
return
73-
}
74-
75-
modulePath := strings.TrimSuffix(string(script.Content), "\n")
68+
modulePath := strings.TrimSuffix(string(scr.Content), "\n")
7669

7770
// Script's content is the path to the wasm script
7871
wasmBytes, err := os.ReadFile(modulePath)
7972
if err != nil {
80-
errs <- fmt.Errorf("failed to read wasm module file %s: %w", script.Content, err)
73+
errs <- fmt.Errorf("failed to read wasm module file %s: %w", scr.Content, err)
8174
return
8275
}
8376

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
outputs =
99
{ self, nixpkgs }:
1010
let
11-
version = "0.7.0";
11+
version = "0.7.1";
1212
vendorHash = "sha256-IsLAIKYuKhlD71fad8FuayTFbdQJla4ifjs8TexXDYQ=";
1313

1414
mkPlugin =

0 commit comments

Comments
 (0)