Let a module stream declare work-queue retention (issue 1177)

This commit is contained in:
jochen
2026-10-19 02:11:05 +02:00
parent ffad53aad2
commit a069898c0c
6 changed files with 206 additions and 3 deletions
+2 -1
View File
@@ -422,7 +422,8 @@ func streamsOf(m catalogue.Manifest) []broker.ModuleStream {
events = append(events, broker.WirePattern(e))
}
out = append(out, broker.ModuleStream{Module: m.Module, Name: s.BusName(), Events: events,
MaxAgeDays: s.Days(), MaxMiB: s.Cap(), Restricted: s.Grant != nil})
MaxAgeDays: s.Days(), MaxMiB: s.Cap(), Restricted: s.Grant != nil,
WorkQueue: s.Retention == catalogue.StreamRetentionWorkQueue, Duplicates: s.Duplicates})
}
return out
}
+22
View File
@@ -43,3 +43,25 @@ func TestWhatAModuleHearsIsComposedOntoTheStreamsSubjects(t *testing.T) {
t.Fatalf("the provider's stream: %+v", got)
}
}
// 1177/AC1: a catalogue stream declaring retention work-queue is carried into the broker's ModuleStream as
// WorkQueue, with its duplicate window.
func TestAWorkQueueStreamIsCarriedIntoTheBrokersModuleStream(t *testing.T) {
sender := catalogue.Manifest{Module: "mesh-mail", Streams: []catalogue.StreamDeclaration{{Name: "mail-sends",
Events: []string{"mail.send.approved"}, MaxAgeDays: 1, MaxMiB: 64,
Retention: catalogue.StreamRetentionWorkQueue, MaxDeliveries: 5, Duplicates: 24}}}
got := streamsOf(sender)
if len(got) != 1 || got[0].Name != "MAIL_SENDS" || !got[0].WorkQueue || got[0].Duplicates != 24 {
t.Fatalf("the sender's stream: %+v", got)
}
}
// 1177/AC3: a catalogue stream with no retention is carried into the broker as not a work queue.
func TestANonWorkQueueStreamIsCarriedAsNotAWorkQueue(t *testing.T) {
plain := catalogue.Manifest{Module: "feed", Streams: []catalogue.StreamDeclaration{{Name: "items",
Events: []string{"item.**"}}}}
got := streamsOf(plain)
if len(got) != 1 || got[0].WorkQueue || got[0].Duplicates != 0 {
t.Fatalf("the plain stream: %+v", got)
}
}