diff --git a/modules/mesh-config/cmd/mesh-config/main.go b/modules/mesh-config/cmd/mesh-config/main.go index 9bfeb5307..3d1a2d9d5 100644 --- a/modules/mesh-config/cmd/mesh-config/main.go +++ b/modules/mesh-config/cmd/mesh-config/main.go @@ -58,18 +58,14 @@ func (r runtimeStore) Get(state, key string) (*Entry, error) { return &Entry{Key: e.Key, Value: e.Value, Revision: e.Revision}, nil } -// Away is the fault `away` while a copy of this module's own states or a first view of an owner is not read yet: a verb or -// tool handler asks it (asking); the module's own start waits for them instead (design 47 H2 H-A-708 (2)). +// Away is the fault `away` while a copy of this module's own states is not read yet: a verb or tool handler asks it +// (asking), the module's own start never does (design 47 H2 H-A-708 (2)). The first views of the owners stay the fault +// `away` at the read itself, since a picture not answered yet is no answer for a pass to resolve from. func (r runtimeStore) Away() error { - if r.own != nil { - if err := r.own.Unread(); err != nil { - return err - } + if r.own == nil { + return nil } - if theViews != nil { - return theViews.Unread() - } - return nil + return r.own.Unread() } // asking is a tool whose handler answers `away` at once while what it reads is not read yet (design 47 H2 H-A-708 (2)). diff --git a/modules/mesh-config/cmd/mesh-config/ownerviews.go b/modules/mesh-config/cmd/mesh-config/ownerviews.go index a25f3ab42..a0d0037d3 100644 --- a/modules/mesh-config/cmd/mesh-config/ownerviews.go +++ b/modules/mesh-config/cmd/mesh-config/ownerviews.go @@ -95,25 +95,16 @@ func (o *ownerViews) read(state string) (*views.Follower, bool) { return f, ok } -// Unread is the fault `away` naming the owner verb of the first view not answered yet, nil when every one is: a verb or tool -// handler asks it before it reads (design 47 H2 H-A-708 (2)). -func (o *ownerViews) Unread() error { - for _, f := range followed { - if err := o.by[f.Read].Unread(); err != nil { - return err - } - } - return nil -} - // get is one key of a followed state. func (o *ownerViews) get(state, key string) (*Entry, bool, error) { f, ok := o.read(state) if !ok { return nil, false, nil } - // The module's own read waits for the first view, never reads an empty picture (design 47 H2 H-A-708 (2), row S8). - <-f.Ready() + // A first view not answered yet is the fault `away`, naming the view's owner verb (design 47 H2 H-A-708 (2)). + if err := f.Unread(); err != nil { + return nil, true, err + } v, held := f.Get(key) if !held { return nil, true, nil @@ -127,7 +118,9 @@ func (o *ownerViews) keys(state string) ([]string, bool, error) { if !ok { return nil, false, nil } - <-f.Ready() + if err := f.Unread(); err != nil { + return nil, true, err + } var out []string for k := range f.Values() { out = append(out, k) diff --git a/modules/mesh-config/cmd/mesh-config/ownerviews_test.go b/modules/mesh-config/cmd/mesh-config/ownerviews_test.go index 65e48f06d..d961539fa 100644 --- a/modules/mesh-config/cmd/mesh-config/ownerviews_test.go +++ b/modules/mesh-config/cmd/mesh-config/ownerviews_test.go @@ -9,7 +9,6 @@ import ( "testing" "time" - stdio "git.novox.be/novox/mesh-sdk/go" "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/views" ) @@ -37,15 +36,9 @@ func TestAFollowedStateIsReadFromItsOwnersFirstViewAndEvents(t *testing.T) { o := newOwnerViews(ask, func() { changed.Add(1) }, nopFindings{}) // H-A-708 (2): a read before the first view is answered `away`, naming the view's owner verb, at once. var away *busretry.Away - if err := o.Unread(); !errors.As(err, &away) || !strings.HasPrefix(away.Part, "mesh-delivery-") || + if _, followed, err := o.get(WantsRead, "want.g14.dunst"); !followed || !errors.As(err, &away) || away.Part != "mesh-delivery-assigner.assigner_read_wants" || !strings.HasPrefix(away.Words, "not read yet since ") { - t.Fatalf("before the first view, a handler's ask: %v", err) - } - c := &Config{Store: runtimeStore{}} - theViews = o - defer func() { theViews = nil }() - if _, err := asking(c, stdio.Tool{Run: func(map[string]any) (any, error) { return nil, nil }}).Run(nil); !errors.As(err, &away) { - t.Fatalf("a tool's handler before an owner view is ready: %v", err) + t.Fatalf("before the first view: followed %v, %v", followed, err) } if !o.reader.Follows("mesh-delivery-assigner.wants") { t.Error("the wants view is not one of the reader's (A-28)")