Keep nothing of a restricted message past its stream's age, only count it (issue 728)
A record kept without its body still carried its subject, which names whose mail it was, with no age. The lead decided such a message is not kept at all: the notice is taken, the message counted, and the log and an aged-out condition say how many messages of the stream aged out undelivered. Unrestricted streams are unchanged.
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -67,3 +68,31 @@ func TestADeadLetterThatAgesOutClearsItsConditionAndSaysSo(t *testing.T) {
|
||||
t.Fatalf("not plain: %s", why)
|
||||
}
|
||||
}
|
||||
|
||||
// **A message past its restricted stream's age is not kept, only counted** (novox/hq ADR 0376, as the feature's lead
|
||||
// decided): its advisory is said as a condition whose words give how many aged out undelivered and from which stream.
|
||||
func TestMessagesNotKeptPastTheirAgeAreCounted(t *testing.T) {
|
||||
now := time.Date(2026, 10, 15, 12, 0, 0, 0, time.UTC)
|
||||
f := calm(now)
|
||||
f.advisories = []link.Advisory{{Kind: link.AdvisoryMaxDeliveries, ID: "MAIL.ace_mailer", Stream: "MAIL",
|
||||
Consumer: "ace_mailer", Token: link.AdvisoryAgedOut, Said: "the consumer gave up after the stream's age",
|
||||
First: now.Add(-10 * time.Minute), Last: now.Add(-time.Minute), Count: 2}}
|
||||
var found []conditions.Observation
|
||||
for _, o := range watchAdvisories(f) {
|
||||
if o.Token == link.AdvisoryAgedOut {
|
||||
found = append(found, o)
|
||||
}
|
||||
}
|
||||
if len(found) != 1 {
|
||||
t.Fatalf("said %+v", found)
|
||||
}
|
||||
o := found[0]
|
||||
if o.Headline != "2 messages of the stream MAIL aged out undelivered" || o.Times != 2 ||
|
||||
!strings.Contains(o.Summary, "2 messages of the stream MAIL aged out undelivered") {
|
||||
t.Fatalf("%+v", o)
|
||||
}
|
||||
if why, ok := conditions.PlainWords(conditions.Words{Headline: o.Headline, Explanation: o.Explanation,
|
||||
Resolved: o.Resolved, Needs: o.Needs}); !ok {
|
||||
t.Fatalf("not plain: %s", why)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,6 +584,18 @@ func watchAdvisories(f *signalFacts) []conditions.Observation {
|
||||
"for you yet. It tries again every minute."
|
||||
o.Resolved = "Resolved: the message is kept"
|
||||
}
|
||||
if a.Kind == link.AdvisoryMaxDeliveries && a.Token == link.AdvisoryAgedOut {
|
||||
// Given up on after its restricted stream's age, so not kept at all, only counted (novox/hq ADR 0376).
|
||||
counted := link.AgedOutWords(a.Count, a.Stream)
|
||||
o.Machine = consumerMachine(a.Stream, a.Consumer)
|
||||
o.Summary = fmt.Sprintf("%s in the last hour: %s", counted, a.Said)
|
||||
o.Headline = clip(conditions.Capital(counted), 60)
|
||||
o.Explanation = conditions.Capital(fmt.Sprintf("%s could not handle %s, and by the time it gave up the "+
|
||||
"stream's time limit had passed, so the mesh did not keep them. Nothing to do; this clears an hour "+
|
||||
"after the last one.", consumerWho(a.Stream, a.Consumer), map[bool]string{true: "some messages",
|
||||
false: "a message"}[a.Count > 1]))
|
||||
o.Resolved = "Resolved: no more messages of the stream " + a.Stream + " aged out undelivered"
|
||||
}
|
||||
out = append(out, o)
|
||||
}
|
||||
if f.busFaultsErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user