layer1: add namespace manager summary
This commit is contained in:
@@ -59,6 +59,7 @@ func (s NamespaceSubscriberFuncs) OnNamespaceResync(ctx context.Context, record
|
||||
type NamespaceManager interface {
|
||||
Snapshot() []string
|
||||
SnapshotRecords() []NamespaceRecord
|
||||
Summary() NamespaceManagerSummary
|
||||
Get(name string) (NamespaceRecord, bool)
|
||||
Bootstrap(namespaces []string, source NamespaceSource, observedAt time.Time) []NamespaceRecord
|
||||
BootstrapAndDispatch(ctx context.Context, namespaces []string, source NamespaceSource, observedAt time.Time) ([]NamespaceRecord, error)
|
||||
@@ -240,6 +241,19 @@ func StartManagedNamespaceWatcher(ctx context.Context, logger *zap.Logger, compo
|
||||
})
|
||||
}
|
||||
|
||||
func (m *inMemoryNamespaceManager) Summary() NamespaceManagerSummary {
|
||||
records := m.SnapshotRecords()
|
||||
summary := NamespaceManagerSummary{
|
||||
TotalNamespaces: len(records),
|
||||
PhaseCounts: make(map[NamespacePhase]int),
|
||||
Subscribers: m.SnapshotSubscribers(),
|
||||
}
|
||||
for _, record := range records {
|
||||
summary.PhaseCounts[record.Phase]++
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
func (m *inMemoryNamespaceManager) Subscribe(subscriber NamespaceSubscriber) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user