G V-5: the views readers adopt a view after their start, and drop one (issue 1966)
A part adopts a watched branch registered while it runs and drops one removed: both go/views readers begin a view followed or adopted after Start at once (its event's one subscription taken first, or reused), read their followers at each event, and Drop ends a view, its row of <module>_first_views (the process's status in first-views) and every finding it raised, cleared through the reader's findings and said in the log. Builds: design 47 G §532, §614 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -5,6 +5,7 @@ package views_test
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -51,7 +52,11 @@ func TestAReaderHearsAnOwnersChangesAsOrdinaryEvents(t *testing.T) {
|
||||
if _, err := r.Follow("o", "modules", "o.o_read_modules"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.Start(ctx, js, cred, nil)
|
||||
statusKV, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: "reader_first-views", Storage: jetstream.MemoryStorage})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.Start(ctx, js, cred, process.AwaitBucket(ctx, js, nil, "reader_first-views", "", t.Logf))
|
||||
<-r.Ready()
|
||||
pic, err := r.KeyValue(ctx, "o_modules")
|
||||
if err != nil {
|
||||
@@ -115,6 +120,16 @@ func TestAReaderHearsAnOwnersChangesAsOrdinaryEvents(t *testing.T) {
|
||||
if s := f.Status(); s.Asks != 1 {
|
||||
t.Errorf("the reader asked its first view %d times across the bursts (%s): a revision written over was taken as a gap", s.Asks, s.Why)
|
||||
}
|
||||
// G §532, §614: a dropped view's status leaves the state first-views, and so its row of <module>_first_views.
|
||||
if _, err := statusKV.Get(ctx, views.StatusKey("o", "modules")); err != nil {
|
||||
t.Fatalf("the status was not kept: %v", err)
|
||||
}
|
||||
if err := r.Drop("o", "modules"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := statusKV.Get(ctx, views.StatusKey("o", "modules")); !errors.Is(err, jetstream.ErrKeyNotFound) {
|
||||
t.Errorf("the dropped view's status is still kept: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A module has one durable consumer on the shared events stream, so the loops that hear events in one module must share
|
||||
|
||||
Reference in New Issue
Block a user