R3 grants-first-view-away: a first view not read yet is the fault away naming its owner's verb
Builds: design 47 H2 H-A-708 (2); row R3 (withheld itself reads the part's own user list, not a first view: question to the lead)
This commit is contained in:
@@ -107,7 +107,7 @@ func (v *toolViews) of(state string) (map[string]json.RawMessage, bool, error) {
|
||||
after = a.Next
|
||||
}
|
||||
if rev == 0 {
|
||||
return nil, true, fmt.Errorf("%s by %s: %w", state, fv.Tool, grants.ErrFirstViewNotYet)
|
||||
return nil, true, fmt.Errorf("%s by %s: %w", state, fv.Tool, grants.NotYet(fv.Tool, "answered empty at revision 0"))
|
||||
}
|
||||
if v.held == nil {
|
||||
v.held = map[string]map[string]json.RawMessage{}
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-grants/grantsstate"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-sdk/go/keys"
|
||||
"git.novox.be/novox/mesh-sdk/go/membership"
|
||||
@@ -3914,6 +3915,16 @@ func TestGrants(t *testing.T) {
|
||||
return last == state
|
||||
}
|
||||
waitFor(t, refusedOnce.Load)
|
||||
// H-A-708 (2): a read of a first view not in yet is mesh-sdk's `away` fault naming the owner's verb, still ErrFirstViewNotYet.
|
||||
for read, f := range fv.Followers {
|
||||
if f.Tool != grants.AssignerModule+".wants" {
|
||||
continue
|
||||
}
|
||||
var away *busretry.Away
|
||||
if _, _, err := fv.Get(read, "k"); !errors.As(err, &away) || away.Part != f.Tool || !errors.Is(err, grants.ErrFirstViewNotYet) {
|
||||
t.Errorf("the first view of %s not in yet is read as %v, not the fault away naming %s", read, err, f.Tool)
|
||||
}
|
||||
}
|
||||
p := partOn(b)
|
||||
p.Read, p.Views, p.Say, p.SayFinding = fv, fv, say, say
|
||||
before := p.Compose()
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
|
||||
occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
||||
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
"git.novox.be/novox/mesh-sdk/go/views"
|
||||
)
|
||||
|
||||
@@ -66,6 +67,19 @@ const KeyFirstViews = "first-views"
|
||||
// ErrFirstViewNotYet is a read of a first view not answered above revision 0: the part composes as from a failed read.
|
||||
var ErrFirstViewNotYet = errors.New("not answered above revision 0 yet")
|
||||
|
||||
// firstViewAway is ErrFirstViewNotYet as mesh-sdk's `away` fault naming the view's owner verb (design 47 H2 H-A-708 (2)): a
|
||||
// caller of the part's read is told that a part it depends on did not answer yet, which it reads as a transport fault and asks
|
||||
// again, never as a refusal.
|
||||
type firstViewAway struct{ *busretry.Away }
|
||||
|
||||
func (e firstViewAway) Is(target error) bool { return target == ErrFirstViewNotYet }
|
||||
func (e firstViewAway) Unwrap() error { return e.Away }
|
||||
|
||||
// NotYet is ErrFirstViewNotYet for the first view of the owner's verb tool, saying why in words.
|
||||
func NotYet(tool, words string) error {
|
||||
return firstViewAway{&busretry.Away{Part: tool, Words: words}}
|
||||
}
|
||||
|
||||
// Views is the part's reads of the five owners' states through their first views: a Reader and a Watcher for those
|
||||
// states, every other read going to Rest.
|
||||
type Views struct {
|
||||
@@ -184,13 +198,15 @@ func (v *Views) ready(read string) (*views.Follower, bool, error) {
|
||||
if !ok {
|
||||
return nil, false, nil
|
||||
}
|
||||
select {
|
||||
case <-f.Ready():
|
||||
default:
|
||||
return f, true, fmt.Errorf("%s by %s: %w", read, f.Tool, ErrFirstViewNotYet)
|
||||
if err := f.Unread(); err != nil {
|
||||
var away *busretry.Away
|
||||
if errors.As(err, &away) {
|
||||
return f, true, fmt.Errorf("%s by %s: %w", read, f.Tool, NotYet(away.Part, away.Words))
|
||||
}
|
||||
return f, true, err
|
||||
}
|
||||
if s := f.Status(); s.Revision == 0 {
|
||||
return f, true, fmt.Errorf("%s by %s answered empty at revision 0: %w", read, f.Tool, ErrFirstViewNotYet)
|
||||
return f, true, fmt.Errorf("%s by %s: %w", read, f.Tool, NotYet(f.Tool, "answered empty at revision 0"))
|
||||
}
|
||||
return f, true, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user