Design 47 H1: a watch of the builds asked again replaces the followed view whole (H-A-257)
A watch asked again after an error handed over the current values on top of the old view, so a key deleted while no watch ran stayed in the keep set. Each handover is now gathered apart and replaces the view whole once it is in, and the ends of keys it no longer holds are forgotten. Builds: design 47 H §H-A-255 (1), §H-A-257
This commit is contained in:
@@ -125,7 +125,8 @@ seat refuses clears it (`sweepseats.go`).
|
||||
A finished build or a changed want marks the one pending pass (design 47 H, H-A-250); a pass running when one is marked
|
||||
runs once more when it ends, however many events marked it. The builder's builds are a followed view: the watch's first view
|
||||
at start, then its updates, kept in memory (H-A-255), each build's end read once from its key's history as it is taken
|
||||
in. A pass reads nothing of them on the bus, judges nothing before the first view is in, and sweeps and observes S25
|
||||
in; a watch asked again after an error replaces the view whole with its handover (H-A-257). A pass reads nothing
|
||||
of them on the bus, judges nothing before the first view is in, and sweeps and observes S25
|
||||
from that one judgement. A list the registry
|
||||
seats cannot answer ends the pass with the finding `artifact-list-unread`, written once; nothing asks the list again
|
||||
until the next event, and a pass that reads it clears the finding (`holder.go`, `sweepseats.go`).
|
||||
|
||||
@@ -123,6 +123,9 @@ func follow(h *Holder, v *views.Reader) {
|
||||
<-stdio.Served()
|
||||
watch := func(state string, handle func(stdio.StateChange) error) {
|
||||
for {
|
||||
if state == BuildsRead {
|
||||
h.Watching() // each handover, the first or one asked again, replaces the view whole (H-A-257)
|
||||
}
|
||||
if err := stdio.State(state).Watch("", handle); err == nil {
|
||||
return
|
||||
} else {
|
||||
|
||||
@@ -106,6 +106,8 @@ type Holder struct {
|
||||
// watch's first view and its updates (Heard); taken says the first view is in. A pass judges from it, reading nothing.
|
||||
done map[string]Build
|
||||
taken bool
|
||||
// next is the handover a watch asked (again) is giving, which replaces done whole once it is in (H-A-257).
|
||||
next map[string]Build
|
||||
}
|
||||
|
||||
// Build is one done build of a module, as its key holds it, with when it ended.
|
||||
@@ -163,18 +165,40 @@ func (h *Holder) Heard(c stdio.StateChange) {
|
||||
return
|
||||
}
|
||||
h.mu.Lock()
|
||||
if h.done == nil {
|
||||
h.done = map[string]Build{}
|
||||
into := h.done
|
||||
if c.Current && h.next != nil {
|
||||
into = h.next
|
||||
}
|
||||
h.done[c.Key] = Build{Module: module, FP: fp, Key: c.Key, At: at, Artifacts: b.Artifacts, Manifest: b.Manifest}
|
||||
if into == nil {
|
||||
h.done = map[string]Build{}
|
||||
into = h.done
|
||||
}
|
||||
into[c.Key] = Build{Module: module, FP: fp, Key: c.Key, At: at, Artifacts: b.Artifacts, Manifest: b.Manifest}
|
||||
h.mu.Unlock()
|
||||
}
|
||||
|
||||
// TakenIn says the view's first view is in: every current value was Heard.
|
||||
// Watching says a watch of the builds is asked, first or again after an error: its handover of current values is
|
||||
// gathered apart and replaces the view whole at TakenIn, so a key deleted while no watch ran leaves it (H-A-257).
|
||||
func (h *Holder) Watching() {
|
||||
h.mu.Lock()
|
||||
h.next = map[string]Build{}
|
||||
h.mu.Unlock()
|
||||
}
|
||||
|
||||
// TakenIn says the watch's handover is in: every current value was Heard. It replaces the view whole, and forgets the
|
||||
// end of every key it no longer holds.
|
||||
func (h *Holder) TakenIn() {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
if h.next != nil {
|
||||
h.done, h.next = h.next, nil
|
||||
for k := range h.ended {
|
||||
if _, kept := h.done[k]; !kept {
|
||||
delete(h.ended, k)
|
||||
}
|
||||
}
|
||||
}
|
||||
h.taken = true
|
||||
h.mu.Unlock()
|
||||
}
|
||||
|
||||
// endOf is when a done key was last written done, read once from its history: a done key is not written again.
|
||||
|
||||
@@ -201,6 +201,7 @@ func TestTheSeatSweepsAtABuildsEndOnARealBusWithNoLease(t *testing.T) {
|
||||
h := &Holder{Bus: findingsAt{realBus: bus}, Findings: findingsThrough{findingsAt{realBus: bus}}, Door: mem.Door, Listed: mem.Listed, Seats: ask, Now: time.Now, Logf: t.Logf}
|
||||
h.Acts = meshhandactsclient.Recorder{Ask: ask}
|
||||
// The followed view of the builds: the six on the bus handed over as the watch's first view does.
|
||||
h.Watching()
|
||||
if keys, err := bus.Keys(BuildsRead); err == nil {
|
||||
for _, k := range keys {
|
||||
raw, _, _ := bus.Get(BuildsRead, k)
|
||||
|
||||
@@ -257,6 +257,7 @@ func aMesh(t *testing.T) (*Holder, *memBus, *memDoor, *[]string) {
|
||||
|
||||
// takeIn hands the builds over as the watch's first view does, then forgets the reads that took: a pass's are counted.
|
||||
func takeIn(h *Holder, b *memBus) {
|
||||
h.Watching()
|
||||
keys, _ := b.Keys(BuildsRead)
|
||||
for _, k := range keys {
|
||||
raw, _, _ := b.Get(BuildsRead, k)
|
||||
@@ -571,6 +572,16 @@ func TestOnePendingPassReadsTheBuildsOnceAndEndsOnAnUnreadList(t *testing.T) {
|
||||
t.Fatalf("a pass before the builds were taken in asked %v", door.asked)
|
||||
}
|
||||
})
|
||||
t.Run("a watch asked again replaces the view whole", func(t *testing.T) {
|
||||
h, b, _, _ := aMesh(t)
|
||||
gone, _ := builds.BuilderBuildKey("letta", fp(3))
|
||||
_ = b.Delete(BuildsRead, gone) // deleted while no watch ran: no change of it is heard
|
||||
takeIn(h, b)
|
||||
got, err := h.Builds()
|
||||
if err != nil || len(got) != 6 || slices.ContainsFunc(got, func(x Build) bool { return x.Key == gone }) {
|
||||
t.Fatalf("after the watch was asked again the view holds %d builds (%v), %s among them", len(got), err, gone)
|
||||
}
|
||||
})
|
||||
t.Run("a list unread ends the pass with its finding once", func(t *testing.T) {
|
||||
h, b, door, _ := aMesh(t)
|
||||
writes, listed, inner := 0, 0, h.Listed
|
||||
|
||||
Reference in New Issue
Block a user