Merge branch 'feat/47-G-fix11-b5g3' into feat/47-G-join11
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
)
|
||||
|
||||
// Design 47 G A-249: a bundle's seat call is received by the runner in chunks only for a verb whose definition says `chunks`,
|
||||
// of no one machine.
|
||||
func TestOnlyAChunkedSeatVerbIsAskedInChunks(t *testing.T) {
|
||||
c := &consumers{definitions: func() map[string]seatdef.Definition {
|
||||
return map[string]seatdef.Definition{"mesh-catalog": {Verbs: []seatdef.Verb{{Name: "input", Chunks: true}, {Name: "entry"}}}}
|
||||
}}
|
||||
for key, want := range map[string]bool{
|
||||
"seat:mesh-catalog.input": true,
|
||||
"seat:mesh-catalog.entry": false,
|
||||
"seat:mesh-catalog.input@ace": false,
|
||||
"seat:mesh-unread.input": false,
|
||||
"mesh-delivery-indexer.indexer": false,
|
||||
} {
|
||||
if got := c.chunked(key); got != want {
|
||||
t.Errorf("chunked(%s) = %v, want %v", key, got, want)
|
||||
}
|
||||
}
|
||||
if (&consumers{}).chunked("seat:mesh-catalog.input") {
|
||||
t.Error("a runner that holds no seat definitions asks no chunks")
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,11 @@ package runtime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/approval"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
|
||||
"github.com/novox/mesh-tools/node-tools/internal/approval"
|
||||
"github.com/novox/mesh-tools/node-tools/internal/launch"
|
||||
)
|
||||
|
||||
@@ -86,3 +87,21 @@ func (r *runner) unservedMarks(module string, regs []launch.Registration) []stri
|
||||
}
|
||||
return r.events.gate.Unserved(module, r.fingerprintOf(module), registered)
|
||||
}
|
||||
|
||||
// chunked says whether key names a seat's verb whose definition says `chunks` (design 47 G A-249): its answer is received in
|
||||
// chunks by the runner, whose call hands the bundle the whole.
|
||||
func (c *consumers) chunked(key string) bool {
|
||||
if c.definitions == nil || !strings.HasPrefix(key, "seat:") {
|
||||
return false
|
||||
}
|
||||
seat, verb, ok := strings.Cut(strings.TrimPrefix(key, "seat:"), ".")
|
||||
if !ok || strings.Contains(verb, "@") {
|
||||
return false
|
||||
}
|
||||
for _, v := range c.definitions()[seat].Verbs {
|
||||
if v.Name == verb {
|
||||
return v.Chunks
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/approval"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatdef"
|
||||
|
||||
"github.com/novox/mesh-tools/node-tools/internal/announce"
|
||||
"github.com/novox/mesh-tools/node-tools/internal/approval"
|
||||
"github.com/novox/mesh-tools/node-tools/internal/bus"
|
||||
"github.com/novox/mesh-tools/node-tools/internal/launch"
|
||||
)
|
||||
@@ -937,7 +937,11 @@ func (b *moduleBus) Ask(params json.RawMessage) (json.RawMessage, error) {
|
||||
if len(asked.Body) == 0 {
|
||||
body = map[string]any{}
|
||||
}
|
||||
answered, err := b.all.conn.AskAs(b.module, asked.Key, body)
|
||||
ask := b.all.conn.AskAs
|
||||
if b.all.chunked(asked.Key) {
|
||||
ask = b.all.conn.AskAsChunked // the runner receives the chunks of the answer; the bundle receives none (design 47 G A-249)
|
||||
}
|
||||
answered, err := ask(b.module, asked.Key, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user