code: func (p *Controller) Wait(ctx context.Context) error {
  	p.logger.Debug("Wait")
  
  	pl, err := p.backend.Get(p.pluginID)
  	if err != nil {
  		return err
  	}
  
  	events, cancel := p.backend.SubscribeEvents(1, plugin.EventDisable{Plugin: pl.PluginObj}, plugin.EventRemove{Plugin: pl.PluginObj}, plugin.EventEnable{Plugin: pl.PluginObj})
  	defer cancel()
  
  	if p.signalWaitReady != nil {
  		p.signalWaitReady()
  	}
  
  	if !p.spec.Disabled != pl.IsEnabled() {
  		return errors.New("mismatched plugin state")
  	}
  
  	for {
  		select {
  		case <-ctx.Done():
  			return ctx.Err()
  		case e := <-events:
  			p.logger.Debugf("got event %T", e)
  
  			switch e.(type) {
  			case plugin.EventEnable:
  				if p.spec.Disabled {
  					return errors.New("plugin enabled")
  				}
  			case plugin.EventRemove:
  				return errors.New("plugin removed")
  			case plugin.EventDisable:
  				if !p.spec.Disabled {
  					return errors.New("plugin disabled")
  				}
  			}
  		}
  	}
  }
docs: // Wait causes the task to wait until returned