Keep a machine's discovery answer under the bus's message limit

Every tool's schema in one $SRV.INFO reply outgrew max_payload on machines
serving 137-206 tools, and the refused reply was dropped silently, so search
and a machine's view went empty. Module tools now announce without schema;
describe and tools/list ask the module for it. An answer still too large has
its descriptions cut to a line, and a failed reply is logged.
This commit is contained in:
jochen
2026-10-04 17:06:20 +02:00
parent 51c79d8461
commit b3ebdd5edd
8 changed files with 184 additions and 10 deletions
+7 -1
View File
@@ -636,7 +636,10 @@ func (c *Conn) ServedOn(module, tool string) []Served { return c.servedOn(module
func (c *Conn) Raw(subject string, answer func(subject string, data []byte) []byte) (func(), error) {
sub, err := c.nc.Subscribe(subject, func(msg *nats.Msg) {
if body := answer(msg.Subject, msg.Data); body != nil {
_ = msg.Respond(body)
// Said, never dropped: an answer the bus will not carry was silence before (2026-10-04).
if err := msg.Respond(body); err != nil {
c.Logf("[mesh-tools] could not answer %s (%d bytes): %v", msg.Subject, len(body), err)
}
}
})
if err != nil {
@@ -679,6 +682,9 @@ func (c *Conn) Gather(subject string, body []byte, window time.Duration) ([][]by
}
}
// MaxPayload is the largest message the bus carries, as the server told this connection.
func (c *Conn) MaxPayload() int64 { return c.nc.MaxPayload() }
// Flush waits until the bus has every subscription made so far, so what is served is answerable
// when this returns.
func (c *Conn) Flush() { _ = c.nc.Flush() }