code: func (c *Collector) Run(ctx context.Context) error {
  	defer close(c.doneChan)
  
  	watcher, cancel, err := store.ViewAndWatch(c.store, func(readTx store.ReadTx) error {
  		nodes, err := store.FindNodes(readTx, store.All)
  		if err != nil {
  			return err
  		}
  		tasks, err := store.FindTasks(readTx, store.All)
  		if err != nil {
  			return err
  		}
  		services, err := store.FindServices(readTx, store.All)
  		if err != nil {
  			return err
  		}
  		networks, err := store.FindNetworks(readTx, store.All)
  		if err != nil {
  			return err
  		}
  		secrets, err := store.FindSecrets(readTx, store.All)
  		if err != nil {
  			return err
  		}
  		configs, err := store.FindConfigs(readTx, store.All)
  		if err != nil {
  			return err
  		}
  
  		for _, obj := range nodes {
  			c.handleEvent(obj.EventCreate())
  		}
  		for _, obj := range tasks {
  			c.handleEvent(obj.EventCreate())
  		}
  		for _, obj := range services {
  			c.handleEvent(obj.EventCreate())
  		}
  		for _, obj := range networks {
  			c.handleEvent(obj.EventCreate())
  		}
  		for _, obj := range secrets {
  			c.handleEvent(obj.EventCreate())
  		}
  		for _, obj := range configs {
  			c.handleEvent(obj.EventCreate())
  		}
  
  		return nil
  	})
  	if err != nil {
  		return err
  	}
  	defer cancel()
  
  	for {
  		select {
  		case event := <-watcher:
  			c.handleEvent(event)
  		case <-c.stopChan:
  			return nil
  		}
  	}
  }
docs: // Run contains the collector event loop