layer1: share watcher namespace manager bootstrap

This commit is contained in:
Naeel
2026-04-26 10:41:14 +03:00
parent d7497dcd34
commit 0e08664ef6
6 changed files with 52 additions and 9 deletions
+12
View File
@@ -88,6 +88,18 @@ func NewBootstrappedNamespaceManager(resolver *NamespaceResolver, source Namespa
return manager
}
func NewWatcherNamespaceManager(ctx context.Context, namespaces []string, source NamespaceSource, observedAt time.Time, subscribers ...NamespaceSubscriber) (NamespaceManager, error) {
manager := NewNamespaceManager()
for _, subscriber := range subscribers {
if subscriber == nil {
continue
}
manager.Subscribe(subscriber)
}
_, err := manager.BootstrapAndDispatch(ctx, namespaces, source, observedAt)
return manager, err
}
func (m *inMemoryNamespaceManager) Subscribe(subscriber NamespaceSubscriber) {
m.mu.Lock()
defer m.mu.Unlock()