Stop stops the watch manager Notifies all subscribers that the database is closing and closes all subscription channels Implements Component interface
(timeout time.Duration)
| 642 | // Notifies all subscribers that the database is closing and closes all subscription channels |
| 643 | // Implements Component interface |
| 644 | func (wm *watchManager) Stop(timeout time.Duration) (err error) { |
| 645 | closeChan := make(chan struct{}) |
| 646 | |
| 647 | // close watch manager |
| 648 | // this cancels context and signals all goroutines to stop |
| 649 | go func() { |
| 650 | err = wm.close() |
| 651 | close(closeChan) |
| 652 | }() |
| 653 | |
| 654 | select { |
| 655 | case <-closeChan: |
| 656 | return err |
| 657 | case <-time.After(timeout): |
| 658 | return ErrCloseWatchManagerTimeout |
| 659 | } |
| 660 | } |