T4: a waiting read lists an ask handed out and not acknowledged, marked again

mesh/queue.waiting reads from each worker's acknowledgement floor, so an ask a worker holds or
handed back is listed with again: true; the holder tells the two apart by its own state taken.

Builds: design 47 H2 §777, H-A-410 (second addendum)
This commit is contained in:
2026-11-22 01:01:59 +01:00
parent 917195a302
commit a6a16c897b
2 changed files with 26 additions and 7 deletions
+8 -4
View File
@@ -19,6 +19,9 @@ type WaitingAsk struct {
ID string `json:"id"`
Module string `json:"module"`
AgeSeconds int64 `json:"age_seconds"`
// Again says the ask was handed to a worker at least once and not acknowledged: held now, or handed back to wait again;
// the holder tells the two apart by its own state taken (H-A-410, second addendum).
Again bool `json:"again,omitempty"`
}
// QueueWaiting is what waits on a seat's work queue, oldest first, and whether the read stopped at QueueWaitingMost.
@@ -34,8 +37,8 @@ func seatStream(seat string) string {
// QueueWaitingOf reads, without consuming, the asks that wait on the seat's work queue for module, the holder whose
// membership lists the queue's workers: its own store (ADR 0596). For each of its workers on the seat's stream, every message
// the worker has not yet been handed (after its delivered sequence) is read by a direct get by subject, never by a consumer
// of its own (design 47 H2 H-A-410).
// after the worker's acknowledgement floor is read by a direct get by subject, never by a consumer of its own; one at or
// below the worker's delivered sequence is marked again (design 47 H2 H-A-410 and its addenda).
func (c *Conn) QueueWaitingOf(module, seat string) (QueueWaiting, error) {
t, err := c.trafficOf(module)
if err != nil {
@@ -77,7 +80,7 @@ func (c *Conn) QueueWaitingOf(module, seat string) (QueueWaiting, error) {
if filter == "" {
filter = ">"
}
for seq := info.Delivered.Stream + 1; ; {
for seq := info.AckFloor.Stream + 1; ; {
m, err := kept.GetMsg(ctx, seq, jetstream.WithGetMsgSubject(filter))
if errors.Is(err, jetstream.ErrMsgNotFound) {
break
@@ -86,7 +89,8 @@ func (c *Conn) QueueWaitingOf(module, seat string) (QueueWaiting, error) {
return QueueWaiting{}, fmt.Errorf("reading %s's queue %s: %w", module, stream, err)
}
seq = m.Sequence + 1
ask := WaitingAsk{Module: m.Header.Get("x-source"), AgeSeconds: int64(now.Sub(m.Time) / time.Second)}
ask := WaitingAsk{Module: m.Header.Get("x-source"), AgeSeconds: int64(now.Sub(m.Time) / time.Second),
Again: m.Sequence <= info.Delivered.Stream}
ask.ID = strings.TrimPrefix(m.Header.Get("x-event-id"), ask.Module+".")
if size += len(ask.ID) + len(ask.Module) + 48; size > QueueWaitingMost {
out.Capped = true