Start starts the watch manager Implements Component interface
(ctx context.Context)
| 607 | // Start starts the watch manager |
| 608 | // Implements Component interface |
| 609 | func (wm *watchManager) Start(ctx context.Context) error { |
| 610 | if wm.isClosed() { |
| 611 | return ErrWatchManagerClosed |
| 612 | } |
| 613 | |
| 614 | wm.muStarted.RLock() |
| 615 | if wm.started { |
| 616 | wm.muStarted.RUnlock() |
| 617 | return nil |
| 618 | } |
| 619 | |
| 620 | wm.started = true |
| 621 | wm.muStarted.RUnlock() |
| 622 | |
| 623 | // use a local ready channel to wait for goroutine startup |
| 624 | ready := make(chan struct{}) |
| 625 | |
| 626 | go func() { |
| 627 | close(ready) // signal that goroutine has started |
| 628 | wm.startDistributor() |
| 629 | }() |
| 630 | |
| 631 | // wait for distributor goroutine to start before returning |
| 632 | select { |
| 633 | case <-ready: |
| 634 | utils.GetLogger().Printf("[watch_manager] Watch manager distributor started\n") |
| 635 | return nil |
| 636 | case <-time.After(5 * time.Second): |
| 637 | return fmt.Errorf("timeout waiting for watch manager distributor to start") |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | // Stop stops the watch manager |
| 642 | // Notifies all subscribers that the database is closing and closes all subscription channels |
nothing calls this directly
no test coverage detected