MH-0: an entry whose ask failed is asked again, at most entry-asks times, then unanswered
The node-engine consumes the entries client's asking again (H-A-60, H-A-110): the setting entry-asks (default 5; module.json config and file resource, read at the engine's start) goes to Entries.Asks; Entries.AskAgain is called at each link's start and on each catalog-revision the composer hears (the shadow's cache too); the finding entry-unanswered joins the engine's finding kinds, written with a journal line when an entry ends unanswered and cleared when it is answered or no longer wanted; the shadow's wait and the have's hold end on it instead of waiting without bound. Builds: design 47 H, H-A-60, H-A-110 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -76,6 +76,7 @@ func (c *Composer) newEntries() {
|
||||
}
|
||||
c.entries = meshcatalogclient.NewEntries(c.env.Entry)
|
||||
c.entries.Now = c.now
|
||||
c.entries.Asks = c.env.EntryAsks
|
||||
c.entries.Changed = c.entryChanged
|
||||
c.keptEnt = map[string]keptEntry{}
|
||||
c.keptWants = map[string]bool{}
|
||||
@@ -153,6 +154,7 @@ func (c *Composer) entryChanged(row meshcatalogclient.EntryRow) {
|
||||
c.keep(entryKey(row.Fingerprint), meshcatalog.EntryAnswer{Entry: *row.Entry})
|
||||
}
|
||||
c.tellNotFound(row.Fingerprint, row.State == meshcatalogclient.EntryNotFound)
|
||||
c.tellUnanswered(row.Fingerprint, row.Asks, row.State == meshcatalogclient.EntryUnanswered)
|
||||
if row.State == meshcatalogclient.EntryAnswered {
|
||||
c.handAgainFor(row.Fingerprint)
|
||||
}
|
||||
@@ -211,6 +213,40 @@ func (c *Composer) tellNotFound(fp string, notFound bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// tellUnanswered tells the finding entry-unanswered once when fp's entry is unanswered, with a journal line saying it, and once when
|
||||
// it no longer is (design 47 H, H-A-60).
|
||||
func (c *Composer) tellUnanswered(fp string, asks int, unanswered bool) {
|
||||
c.mu.Lock()
|
||||
was := c.unanswered[fp]
|
||||
if was == unanswered {
|
||||
c.mu.Unlock()
|
||||
return
|
||||
}
|
||||
if c.unanswered == nil {
|
||||
c.unanswered = map[string]bool{}
|
||||
}
|
||||
if unanswered {
|
||||
c.unanswered[fp] = true
|
||||
} else {
|
||||
delete(c.unanswered, fp)
|
||||
}
|
||||
c.mu.Unlock()
|
||||
if unanswered {
|
||||
c.env.Say(fmt.Sprintf("the entry of the build %s is unanswered: its ask failed to reach the catalog half's holder %d times more, so the node composes nothing new of it until it is asked again (the seat node-engine's verb entry-again)", fp, asks))
|
||||
}
|
||||
if c.env.EntryUnanswered != nil {
|
||||
c.env.EntryUnanswered(fp, asks, unanswered)
|
||||
}
|
||||
}
|
||||
|
||||
// EntriesAskAgain asks again every entry whose last ask failed in transport (meshcatalogclient.Entries.AskAgain): the node agent
|
||||
// calls it when its link to the bus opens (design 47 H, H-A-60).
|
||||
func (c *Composer) EntriesAskAgain(ctx context.Context) {
|
||||
if c.entries != nil {
|
||||
c.entries.AskAgain(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// keep writes one value into the composition state; a state that cannot be written is said, and the value is kept again by
|
||||
// the next pass.
|
||||
func (c *Composer) keep(key string, v any) {
|
||||
@@ -318,6 +354,7 @@ func (c *Composer) syncEntries(ctx context.Context) {
|
||||
if _, named := need[row.Fingerprint]; !named && !added {
|
||||
c.entries.Release(row.Fingerprint)
|
||||
c.tellNotFound(row.Fingerprint, false)
|
||||
c.tellUnanswered(row.Fingerprint, 0, false)
|
||||
}
|
||||
}
|
||||
c.mu.Lock()
|
||||
@@ -701,6 +738,9 @@ func (c *Composer) entryHolds() map[string]string {
|
||||
case meshcatalogclient.EntryAsked:
|
||||
out[module] = fmt.Sprintf("%s the entry of the build %s is asked of the catalog half and not yet answered, so the node composes nothing new of %s",
|
||||
agent.EntryAsked, w.Fp, module)
|
||||
case meshcatalogclient.EntryUnanswered:
|
||||
out[module] = fmt.Sprintf("%s the entry of the build %s is unanswered: its ask failed to reach the catalog half as often as the setting entry-asks allows, so the node composes nothing new of %s",
|
||||
agent.EntryAsked, w.Fp, module)
|
||||
case meshcatalogclient.EntryNotFound:
|
||||
out[module] = fmt.Sprintf("%s the catalog half holds no entry of the build %s, so the node composes nothing new of %s",
|
||||
agent.EntryMissing, w.Fp, module)
|
||||
@@ -951,6 +991,8 @@ func (c *Composer) addedModule(ctx context.Context, module string) (fp string, e
|
||||
return fp, e, true, false, ""
|
||||
case meshcatalogclient.EntryNotFound:
|
||||
return fp, e, false, false, fmt.Sprintf("the catalog half holds no entry of %s's build %s", module, fp)
|
||||
case meshcatalogclient.EntryUnanswered:
|
||||
return fp, e, false, false, fmt.Sprintf("the entry of %s's build %s is unanswered: its ask failed to reach the catalog half as often as the setting entry-asks allows", module, fp)
|
||||
}
|
||||
return fp, e, false, true, fmt.Sprintf("the entry of %s's build %s is asked of the catalog half and not yet answered", module, fp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user