go-vise

Constrained Size Output Virtual Machine
Info | Log | Files | Refs | README | LICENSE

commit 400f69d01a893f944df90b8ff73edfa6d7bb8c21
parent ce975aca953f0634a98d7a0ecdbd1f8fadf3cdac
Author: lash <dev@holbrook.no>
Date:   Fri,  6 Sep 2024 03:06:35 +0100

Capture sessionId and language in ctx for both init and exec

Diffstat:
Mengine/db.go | 17++++++++++-------
Mvm/runner.go | 1+
2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/engine/db.go b/engine/db.go @@ -358,6 +358,12 @@ func(en *DefaultEngine) Init(ctx context.Context) (bool, error) { logg.DebugCtxf(ctx, "already initialized") return true, nil } + if en.cfg.SessionId != "" { + ctx = context.WithValue(ctx, "SessionId", en.cfg.SessionId) + } + if en.st.Language != nil { + ctx = context.WithValue(ctx, "Language", *en.st.Language) + } sym := en.cfg.Root if sym == "" { @@ -408,16 +414,13 @@ func(en *DefaultEngine) Init(ctx context.Context) (bool, error) { // * input processing against bytcode failed func (en *DefaultEngine) Exec(ctx context.Context, input []byte) (bool, error) { var err error + if en.cfg.SessionId != "" { + ctx = context.WithValue(ctx, "SessionId", en.cfg.SessionId) + } if en.st.Language != nil { ctx = context.WithValue(ctx, "Language", *en.st.Language) } - if en.st.Moves == 0 { - cont, err := en.Init(ctx) - if err != nil { - return false, err - } - return cont, nil - } + err = vm.ValidInput(input) if err != nil { return true, err diff --git a/vm/runner.go b/vm/runner.go @@ -479,6 +479,7 @@ func(vm *Vm) refresh(key string, rs resource.Resource, ctx context.Context) (str input, _ := vm.st.GetInput() r, err := fn(ctx, key, input) if err != nil { + logg.Errorf("external function load fail", "key", key, "error", err) _ = vm.st.SetFlag(state.FLAG_LOADFAIL) return "", NewExternalCodeError(key, err).WithCode(r.Status) }