layer1: add namespace summary active helper

This commit is contained in:
Naeel
2026-04-26 11:46:47 +03:00
parent 9f0e911b9d
commit fed69da335
3 changed files with 29 additions and 0 deletions
@@ -2,6 +2,20 @@
## Цель шага
Добавить маленький, но полезный helper поверх summary/debug contract: проверку, есть ли вообще живые namespace-ы.
## Что меняем
1. В `NamespaceManagerSummary` добавляем `HasActiveNamespaces()`.
2. Добавляем unit tests на true/false path.
## Что НЕ меняем
- не меняем summary counters;
- не меняем watcher behavior.# 2026-04-26 — NamespaceManager rewrite, step 48
## Цель шага
Убрать двусмысленность в `NamespaceManagerSummary`: сейчас `TotalNamespaces` включает и removed-записи.
## Что меняем
+4
View File
@@ -81,6 +81,10 @@ type NamespaceManagerSummary struct {
Subscribers []string
}
func (summary NamespaceManagerSummary) HasActiveNamespaces() bool {
return summary.LiveNamespaces > 0
}
type ManagedNamespaceWatcherConfig struct {
Component string
Namespaces []string
+11
View File
@@ -161,3 +161,14 @@ func TestNamespaceManagerSummaryZeroValue(t *testing.T) {
t.Fatalf("expected zero total namespaces")
}
}
func TestNamespaceManagerSummaryHasActiveNamespaces(t *testing.T) {
summary := NamespaceManagerSummary{LiveNamespaces: 1}
if !summary.HasActiveNamespaces() {
t.Fatalf("expected positive live count to report active namespaces")
}
summary.LiveNamespaces = 0
if summary.HasActiveNamespaces() {
t.Fatalf("expected zero live count to report no active namespaces")
}
}