Indexer: the revision verb answers the newest kept revision from the store
The tools bundle answered the catalog seat's revision verb from its view of the trunk in memory, which ran one or more revisions behind what the indexer kept until it heard the event, so the runner and the builder waited on revisions the bus held all along. The verb now reads which revision is newest from the store at the time of the ask (a listing and one object) and takes the view's entries only when the view holds that very revision. Builds: design 47 H-A-222 (1), H-A-205, H-A-213
This commit is contained in:
@@ -93,16 +93,20 @@ func TestTheKeptTrunkIsReadAtTheStartAndOncePerHeardRevision(t *testing.T) {
|
||||
if e, ok, err := modules.Get("ca-trust"); err != nil || !ok || e.Revision != 2 {
|
||||
t.Errorf("after the event ca-trust = %+v %v (%v), want it at revision 2", e, ok, err)
|
||||
}
|
||||
// A-487c: the manifests by digest and the verb revision asked of the trunk's newest answer from the view held.
|
||||
// A-487c: the manifests by digest answer from the view held; the verb revision asked of the trunk's newest lists the bucket
|
||||
// once for which revision is newest (H-A-222) and takes the entries of the view held at that very revision.
|
||||
listed = objects.n.Load()
|
||||
if raw, err := kept.Manifest(meshcatalogclient.BareManifestDigest(keptDigest("ca-trust"))); err != nil || raw != `{"module":"ca-trust"}` {
|
||||
t.Errorf("the held manifest = %q (%v), want the entry's manifest", raw, err)
|
||||
}
|
||||
if got := objects.n.Load() - listed; got != 0 {
|
||||
t.Errorf("the manifest listed the bucket %d times, want none", got)
|
||||
}
|
||||
if a, err := Revision(context.Background(), objects, kept, meshcatalog.RevisionInput{}); err != nil || a.Revision.Revision != 2 || len(a.Entries) != 2 {
|
||||
t.Errorf("revision of the newest answered %+v (%v), want revision 2 whole", a, err)
|
||||
}
|
||||
if got := objects.n.Load() - listed; got != 0 {
|
||||
t.Errorf("the manifest and the verb revision listed the bucket %d times, want none", got)
|
||||
if got := objects.n.Load() - listed; got != 1 {
|
||||
t.Errorf("the verb revision listed the bucket %d times, want once, for the newest", got)
|
||||
}
|
||||
if len(said) != 2 || !strings.Contains(said[1], "read revision 2 (was 1), 2 modules, in ") {
|
||||
t.Errorf("said %q, want each read with its revision, module count and time", said)
|
||||
@@ -126,6 +130,16 @@ func TestTheKeptTrunkIsReadAtTheStartAndOncePerHeardRevision(t *testing.T) {
|
||||
if keys, _ := modules.Keys(); len(keys) != 3 {
|
||||
t.Errorf("the next heard event left the view at %v, want revision 3's three modules", keys)
|
||||
}
|
||||
// H-A-222: two revisions kept that the view has not heard are answered by the verb revision from the store, whole; the
|
||||
// view held stays a cache at its own revision.
|
||||
keep(4, "avahi", "ca-trust", "dbus")
|
||||
keep(5, "avahi", "ca-trust", "dbus", "feh")
|
||||
if a, err := Revision(context.Background(), objects, kept, meshcatalog.RevisionInput{}); err != nil || a.Revision == nil || a.Revision.Revision != 5 || len(a.Entries) != 4 {
|
||||
t.Errorf("revision of the newest answered %+v (%v) while the view held 3, want revision 5 whole from the store", a, err)
|
||||
}
|
||||
if keys, _ := modules.Keys(); len(keys) != 3 {
|
||||
t.Errorf("the verb moved the view held to %v, want it at revision 3 until it hears the event", keys)
|
||||
}
|
||||
}
|
||||
|
||||
// A-487: the verb module reads the one module it is asked.
|
||||
|
||||
@@ -23,17 +23,22 @@ const RevisionInvoke = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbRevisi
|
||||
// H-A-66: every account may call every verb). With no trunk revision kept yet the answer is `none-yet` alone (design 47 G §530), never an empty
|
||||
// catalog and never an error.
|
||||
//
|
||||
// kept, when not nil, is the trunk's newest revision held in memory: the trunk's newest answers from it with no read of
|
||||
// the bucket (A-487c); a candidate, a branch and an older number read the bucket.
|
||||
// The trunk's newest is the newest the bucket keeps at the time of the ask, read from the store (a listing of the names and
|
||||
// one object, design 47 H-A-222), never the view held in memory, which runs behind until it hears the revision. kept, when
|
||||
// not nil, is that view: a cache of the entries only, used when it holds the very revision read; else the entries are read
|
||||
// from the bucket. A candidate, a branch and an older number read the bucket.
|
||||
func Revision(ctx context.Context, o Objects, kept *KeptTrunk, in meshcatalog.RevisionInput) (meshcatalog.RevisionAnswer, error) {
|
||||
var out meshcatalog.RevisionAnswer
|
||||
var newest meshcatalog.CatalogRevision
|
||||
var ok bool
|
||||
var trunkEntries, branchEntries []meshcatalog.CatalogEntry
|
||||
var err error
|
||||
if kept != nil {
|
||||
newest, trunkEntries, ok, err = kept.Newest(ctx, o)
|
||||
} else {
|
||||
newest, ok, err := newestOf(ctx, o, TrunkBranch)
|
||||
cached := false
|
||||
if err == nil && ok && kept != nil {
|
||||
if held, entries, any, kerr := kept.Newest(ctx, o); kerr == nil && any && held.Revision == newest.Revision {
|
||||
trunkEntries, cached = entries, true
|
||||
}
|
||||
}
|
||||
if !cached && (err != nil || ok) {
|
||||
// readNewestOf reads the entries whole, and the newest again when the pin judge removed one under the read.
|
||||
newest, trunkEntries, ok, err = readNewestOf(ctx, o, TrunkBranch)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user