node-engine: compose-candidate sends its composition input in chunks over the link's connection when asked with a call token (A-237b)
Builds: design 47 G (G-22 lead answers 2) A-237b; A-237, A-249
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/nodeengine"
|
||||
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/seatlist"
|
||||
@@ -53,6 +54,9 @@ type EngineCall struct {
|
||||
Verb string
|
||||
Caller string
|
||||
Args map[string]any
|
||||
// Line is the link's bus connection, which a verb marked chunks sends its answer's file on (buscalls.SeatChunks.Send); nil
|
||||
// where the call did not come over a live link.
|
||||
Line buscalls.ChunkLine
|
||||
}
|
||||
|
||||
// EngineFunc answers one call: its result, or why it is refused.
|
||||
@@ -162,9 +166,13 @@ func (l *natsLink) serveEngineSeat(handle EngineFunc, module string) {
|
||||
return
|
||||
}
|
||||
apart := make(chan struct{}, apartAtOnce)
|
||||
withLine := func(c EngineCall) (any, error) {
|
||||
c.Line = l.conn // a verb marked chunks sends its file on the link's own connection
|
||||
return handle(c)
|
||||
}
|
||||
for _, v := range ServedEngineSeat().Serves {
|
||||
verb := v.Name
|
||||
answer := EngineAnswer(handle, verb, l.node, apart)
|
||||
answer := EngineAnswer(withLine, verb, l.node, apart)
|
||||
meta := EngineEndpointMetadata(v, l.node, module)
|
||||
_ = svc.AddEndpoint(verb, answer, micro.WithEndpointSubject(EngineToolSubject(verb, l.node)),
|
||||
micro.WithEndpointMetadata(meta))
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.novox.be/novox/mesh-sdk/go/buscalls"
|
||||
sdkkeys "git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -175,7 +176,8 @@ type HandActs struct {
|
||||
// ComposeCandidate composes a check's candidate (the indexer's candidate key) on this node in shadow and answers per
|
||||
// module, applying and writing nothing; with input, also the composition input it composed from (the verb
|
||||
// compose-candidate, ADR 0593 §7).
|
||||
ComposeCandidate func(candidate string, input bool) (any, error)
|
||||
// call is the caller's token for the chunks the input is sent in (A-237b) and line the connection they go on; with no token the input is inline.
|
||||
ComposeCandidate func(candidate string, input bool, call string, line buscalls.ChunkLine) (any, error)
|
||||
// ManifestReads is what this engine states it reads of a manifest and when its record last carried them (the verb
|
||||
// manifest-reads, novox/hq ADR 0618 §3).
|
||||
ManifestReads func() ([]string, time.Time)
|
||||
@@ -289,7 +291,7 @@ func (h *HandActs) Call(c EngineCall) (any, error) {
|
||||
if b, ok := c.Args["input"].(bool); ok {
|
||||
input = b
|
||||
}
|
||||
return h.ComposeCandidate(arg("candidate"), input)
|
||||
return h.ComposeCandidate(arg("candidate"), input, arg("call"), c.Line)
|
||||
case ActManifestReads:
|
||||
if h.ManifestReads == nil {
|
||||
return nil, errors.New("this engine states no manifest reads yet: its node agent has not started")
|
||||
|
||||
@@ -238,7 +238,9 @@ func (s *Shadow) composeCandidate(ctx context.Context, c *Composer, ask nodeengi
|
||||
}
|
||||
}
|
||||
})
|
||||
if sentSize > maxSentInput {
|
||||
// An ask with a call token takes the input in chunks, whatever its size (A-237b); one with none is the checker's, answered
|
||||
// inline until G removes the checker (G-6 §321), so past what the bus carries in one answer it is refused.
|
||||
if sentSize > maxSentInput && ask.Call == "" {
|
||||
// Past what the bus carries in one answer, the checker would hear nothing: refused, saying so.
|
||||
size := sentSize
|
||||
a.Input = nil
|
||||
|
||||
Reference in New Issue
Block a user