H-A-227: answer an object store's fill from its stream's own figures

The fill was a listing of every description in the store, deleted chunks'
leftovers included; a receiver reading it per chunk made one connection read
about 14 MB/s. The fill is now one stream info request: its bytes, its cap,
and its live subjects as the count.

Builds: design 47 H H-A-227
This commit is contained in:
2026-11-21 01:59:38 +01:00
parent 07f5aa11c3
commit 3eef0254df
3 changed files with 55 additions and 14 deletions
@@ -5,6 +5,7 @@ import (
"testing"
"git.novox.be/novox/mesh-sdk/go/buscalls"
"github.com/nats-io/nats.go/jetstream"
)
// novox/hq ADR 0363 §2, §3: an event goes to the stream whose pattern carries it, as the bus matches subjects.
@@ -69,3 +70,19 @@ func TestAnEventNoStreamCarriesIsPublishedOnEvents(t *testing.T) {
t.Errorf("a stream's event reaches its consumer as %q, not as on EVENTS", got)
}
}
// Design 47 H lead answers H-A-227: an object store's fill is the figures the bus keeps for its stream, its live
// subjects as the count, never a count of its descriptions: a store holding twenty thousand messages, deleted chunks'
// leftovers among them, answers its bytes, its cap and its four live subjects.
func TestAnObjectStoresFillIsItsStreamsOwnFigures(t *testing.T) {
info := &jetstream.StreamInfo{
Config: jetstream.StreamConfig{MaxBytes: 8 << 30},
State: jetstream.StreamState{Msgs: 20653, Bytes: 1 << 30, NumSubjects: 4, FirstSeq: 9, LastSeq: 20661},
}
if got, want := objectsFillOf(info), (buscalls.Fill{Count: 4, Bytes: 1 << 30, MaxBytes: 8 << 30}); got != want {
t.Fatalf("fill %+v, want %+v", got, want)
}
if got := objectsFillOf(&jetstream.StreamInfo{State: jetstream.StreamState{Bytes: 7}}); got != (buscalls.Fill{Bytes: 7}) {
t.Fatalf("a store with no cap and no live subject: fill %+v", got)
}
}