code: func (m *Manager) ensureProxyServiceLocked(ns *structs.NodeService, token string) error {
  	state, ok := m.proxies[ns.ID]
  
  	if ok {
  		if !state.Changed(ns, token) {
  			// No change
  			return nil
  		}
  
  		// We are updating the proxy, close it's old state
  		state.Close()
  	}
  
  	var err error
  	state, err = newState(ns, token)
  	if err != nil {
  		return err
  	}
  
  	// Set the necessary dependencies
  	state.logger = m.Logger
  	state.cache = m.Cache
  	state.source = m.Source
  
  	ch, err := state.Watch()
  	if err != nil {
  		return err
  	}
  	m.proxies[ns.ID] = state
  
  	// Start a goroutine that will wait for changes and broadcast them to watchers.
  	go func(ch <-chan ConfigSnapshot) {
  		// Run until ch is closed
  		for snap := range ch {
  			m.notify(&snap)
  		}
  	}(ch)
  
  	return nil
  }
docs: // ensureProxyServiceLocked adds or changes the proxy to our state.