R1-3: the waiting read names a seat's stream by mesh-sdk's one derivation
seatStream derived the stream name itself and kept '.' where buscompose.SeatQueueStreamName writes '_'; QueueWaitingOf now calls buscompose (review round 1, finding 3, queue.go:34). Builds: design 47 H2 §777, H-A-410, P9
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/buscompose"
|
||||
)
|
||||
|
||||
// QueueWaitingMost is the most a waiting read holds, in its asks' ids and modules (design 47 H2 H-A-410).
|
||||
@@ -30,11 +32,6 @@ type QueueWaiting struct {
|
||||
Capped bool `json:"capped,omitempty"`
|
||||
}
|
||||
|
||||
// seatStream is the work-queue stream a seat's asks are kept on.
|
||||
func seatStream(seat string) string {
|
||||
return "SEAT_" + strings.ToUpper(strings.ReplaceAll(seat, "-", "_"))
|
||||
}
|
||||
|
||||
// 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
|
||||
// after the worker's acknowledgement floor is read by a direct get by subject, never by a consumer of its own; one at or
|
||||
@@ -44,7 +41,8 @@ func (c *Conn) QueueWaitingOf(module, seat string) (QueueWaiting, error) {
|
||||
if err != nil {
|
||||
return QueueWaiting{}, err
|
||||
}
|
||||
stream := seatStream(seat)
|
||||
// The work-queue stream a seat's asks are kept on, by the one derivation every part takes (H-A-410, P9).
|
||||
stream := buscompose.SeatQueueStreamName(seat)
|
||||
var workers []SeatWorker
|
||||
for _, w := range t.Workers {
|
||||
if w.Stream == stream {
|
||||
|
||||
@@ -222,9 +222,13 @@ func TestABundlePullsAndSettlesThroughItsModulesBus(t *testing.T) {
|
||||
}
|
||||
// Design 47 H2 H-A-410: the holder reads what waits on its own queue of the seat without consuming it (mesh/queue.waiting),
|
||||
// each ask with its id, the module that put it and its age; another module is refused, as is a seat it holds no queue of.
|
||||
waiting := func(want string) {
|
||||
waiting := func(want string, spelled ...string) {
|
||||
t.Helper()
|
||||
raw, err := building.Seat("waiting", json.RawMessage(`{"seat":"node-build-go"}`), nil)
|
||||
seat := "node-build-go"
|
||||
if len(spelled) > 0 {
|
||||
seat = spelled[0]
|
||||
}
|
||||
raw, err := building.Seat("waiting", json.RawMessage(`{"seat":"`+seat+`"}`), nil)
|
||||
var w bus.QueueWaiting
|
||||
if err != nil || json.Unmarshal(raw, &w) != nil || w.Capped {
|
||||
t.Fatalf("waiting = %s, %v", raw, err)
|
||||
@@ -274,4 +278,6 @@ func TestABundlePullsAndSettlesThroughItsModulesBus(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waiting("mesh-delivery-pipeline:ask2:true:again")
|
||||
// the seat's stream is the one mesh-sdk's buscompose names, '.' as '_' too (H-A-410, P9)
|
||||
waiting("mesh-delivery-pipeline:ask2:true:again", "node-build.go")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user