[v3] Binding runtime fixes (#3431)

* Unmarshal arguments to appropriate type in binding calls

* Marshal multiple return values to arrays in binding calls

* Improve logging of remote method calls

* Add tests for `BoundMethod.Call`

* Fix return value if error is nil

* Update changelog

---------

Co-authored-by: Andreas Bichinger <andreas.bichinger@gmail.com>
This commit is contained in:
Fabio Massaioli
2024-05-05 18:32:25 +10:00
committed by Lea Anthony
co-authored by Andreas Bichinger
parent 6f03d9e316
commit b0bce075da
4 changed files with 269 additions and 56 deletions
+9 -4
View File
@@ -81,16 +81,16 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
ctx, cancel := context.WithCancel(context.WithoutCancel(r.Context()))
ambigiousID := false
ambiguousID := false
m.l.Lock()
if m.runningCalls[*callID] != nil {
ambigiousID = true
ambiguousID = true
} else {
m.runningCalls[*callID] = cancel
}
m.l.Unlock()
if ambigiousID {
if ambiguousID {
cancel()
m.callErrorCallback(window, "Error calling method: %s, a method call with the same id is already running", callID, err)
return
@@ -130,7 +130,12 @@ func (m *MessageProcessor) processCallMethod(method int, rw http.ResponseWriter,
}
}
m.callCallback(window, callID, string(jsonResult), true)
m.Info("Call Binding:", "method", boundMethod, "args", options.Args, "result", result)
var jsonArgs struct {
Args json.RawMessage `json:"args"`
}
params.ToStruct(&jsonArgs)
m.Info("Call Binding:", "method", boundMethod, "args", string(jsonArgs.Args), "result", result)
}()
m.ok(rw)
default: