MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / Start

Method Start

watch_manager.go:609–639  ·  view source on GitHub ↗

Start starts the watch manager Implements Component interface

(ctx context.Context)

Source from the content-addressed store, hash-verified

607// Start starts the watch manager
608// Implements Component interface
609func (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

Callers

nothing calls this directly

Calls 4

isClosedMethod · 0.95
startDistributorMethod · 0.95
GetLoggerFunction · 0.92
PrintfMethod · 0.65

Tested by

no test coverage detected