layer1: share watcher namespace manager bootstrap
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user