H-A-196: a process pulls a durable consumer once

A second pull loop on a durable the same process already pulls takes every other
event from the first, and nothing said so: the tool runner's two loops on the
indexer bundle's durable left the catalog seat's revision verb stale twice today.
The SDK now refuses it at bind time, naming the durable and both binders:
PullOnce claims a durable (by stream, name and the time the bus made it), and
HearEvents and Conn.Consume claim through it, releasing on stop, drain or the
bus ending the loop.

Builds: design 47 H H-A-196
This commit is contained in:
2026-11-20 22:05:14 +01:00
parent c15460faf5
commit c1c369f50c
5 changed files with 160 additions and 3 deletions
+10 -1
View File
@@ -4,6 +4,7 @@ package process
import (
"context"
"strings"
"testing"
"time"
@@ -90,15 +91,23 @@ func TestConsumeAckRemovesTheMessageFromTheStream(t *testing.T) {
defer conn.Close()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
got := make(chan *Message, 1)
got, second := make(chan *Message, 1), make(chan error, 1)
go func() {
_ = conn.Consume(ctx, "MAIL_SENDS", func(m *Message) {
// A second pull loop on the durable this process pulls is refused at bind time (design 47 H, H-A-196).
short, stop := context.WithTimeout(context.Background(), time.Second)
second <- conn.Consume(short, "MAIL_SENDS", func(*Message) {})
stop()
got <- m
cancel()
})
}()
msg := recv(t, got, 8*time.Second, "the message")
<-ctx.Done()
if err := <-second; err == nil || !strings.Contains(err.Error(), "pulled in this process already") ||
!strings.Contains(err.Error(), account.QueueConsumerName()) {
t.Fatalf("a second Consume of the queue the process pulls was not refused naming its durable: %v", err)
}
if err := msg.Ack(); err != nil {
t.Fatalf("Ack: %v", err)
}