@@ -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
2223type 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
0 commit comments