Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39c2604926 | ||
|
|
07f5aa11c3 | ||
|
|
876adfbf05 | ||
|
|
c952386737 |
@@ -7,6 +7,8 @@
|
||||
// mesh.seat.<seat>.tool.<verb> a role's verb, answered by whoever holds the seat
|
||||
// mesh.mod.<module>.call.<tool>.<caller>, mesh.seat.<seat>.call.<verb>.<caller>
|
||||
// the same, naming the bus user that called (caller.go, hq issue 365)
|
||||
//
|
||||
// Design 47 H1, proof 2: the SDK and its importer delivered in one merge call, 2026-11-21.
|
||||
package bus
|
||||
|
||||
import (
|
||||
|
||||
@@ -77,6 +77,8 @@ func TestAConsumerSaysItIsBoundWhileIdleAndOnceWhenTheBusEndedIt(t *testing.T) {
|
||||
}
|
||||
}))
|
||||
mesh.Consumer(t, "anchor", "quiet", []string{"mesh.mod.alpha.event.>"}, time.Second)
|
||||
// The unasked consume below pulls a durable of its own: a second loop on quiet's is refused (H-A-196, H-A-197).
|
||||
mesh.Consumer(t, "anchor", "unasked", []string{"mesh.mod.alpha.event.>"}, time.Second)
|
||||
c, err := bus.Connect(bus.Credential{URL: mt.URL(t), Module: "node-tools", Node: "anchor"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -97,7 +99,7 @@ func TestAConsumerSaysItIsBoundWhileIdleAndOnceWhenTheBusEndedIt(t *testing.T) {
|
||||
t.Cleanup(stop)
|
||||
// A consume nobody asked a heartbeat of says nothing and asks the bus nothing, however many intervals pass.
|
||||
var unaskedBeats atomic.Int32
|
||||
unasked, err := c.ConsumeAsBeatingWhen("quiet", func(bus.Envelope) error { return nil },
|
||||
unasked, err := c.ConsumeAsBeatingWhen("unasked", func(bus.Envelope) error { return nil },
|
||||
func(bus.Beat) { unaskedBeats.Add(1) }, func() bool { return false })
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
)
|
||||
|
||||
// A module's own stream, as the runtime publishes to it and hears it (novox/hq ADR 0363 §8, issue 725).
|
||||
@@ -129,7 +131,10 @@ func (h *hearing) bind(stream, durable string, onErr func(error)) (jetstream.Con
|
||||
if onErr != nil {
|
||||
opts = append(opts, jetstream.ConsumeErrHandler(func(_ jetstream.ConsumeContext, err error) { onErr(err) }))
|
||||
}
|
||||
reading, err := consumer.Consume(h.handle, opts...)
|
||||
// Claimed through the SDK's one guard as it is pulled (design 47 H, H-A-196, H-A-197): a second pull loop on a durable
|
||||
// this process pulls already would take every other event from the first, so it is refused here, loud. The claim is
|
||||
// released as the loop is stopped, or once the bus ended it, before its Closed is closed.
|
||||
reading, err := process.ConsumeOnce(consumer, "the tool runner's hearing of "+h.module, h.handle, opts...)
|
||||
if err != nil {
|
||||
return nil, time.Time{}, "reading", err
|
||||
}
|
||||
|
||||
@@ -258,6 +258,34 @@ func TestAConsumerNamedBeforeItExistsIsBoundOnceItDoes(t *testing.T) {
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
// A second pull loop on the durable the runner pulls is refused, naming it and both binders (design 47 H, H-A-196,
|
||||
// H-A-197); a re-serve that stops its loop first binds again without a refusal, its module stream's durable too.
|
||||
if _, err := conn.ConsumeAs("reader", func(bus.Envelope) error { return nil }); err == nil ||
|
||||
!strings.Contains(err.Error(), "pulled in this process already") || !strings.Contains(err.Error(), "anchor_reader") ||
|
||||
strings.Count(err.Error(), "the tool runner's hearing of reader") != 2 {
|
||||
t.Fatalf("a second pull loop on the durable the runner pulls was not refused naming it and both binders: %v", err)
|
||||
}
|
||||
stop()
|
||||
again, err := conn.ConsumeAs("reader", func(env bus.Envelope) error {
|
||||
mu.Lock()
|
||||
heard[env.Key]++
|
||||
mu.Unlock()
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("the re-serve was refused after its old loop stopped: %v", err)
|
||||
}
|
||||
t.Cleanup(again)
|
||||
mesh.Emit(t, "mesh.stream.mail.event.mail.home.message.added", map[string]any{})
|
||||
mt.Until(t, func() error {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if heard["mail.mail.home.message.added"] != 2 {
|
||||
return fmt.Errorf("after the re-serve heard %v", heard)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// novox/hq ADR 0363 §6 (issue 725): a consumer the controller deletes and makes again under the same name, its
|
||||
|
||||
Reference in New Issue
Block a user