// Unregister removes an existing plugin from the registry. If no plugin with
// the provided name exists, it returns an error.
358025
func (r Registry) Unregister(name string) error {
	if _, ok := r[name]; !ok {
		return fmt.Errorf("no plugin named %v exists", name)
	}
	delete(r, name)
	return nil
}
876316
func deleteFromRegistry(registryClient *http.Client, url string) error {
	req, err := http.NewRequest(http.MethodDelete, url, nil)
	if err != nil {
		return err
	}

	klog.V(5).Infof(`Sending request "%s %s" to the registry`, req.Method, req.URL.String())
	resp, err := registryClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	// TODO: investigate why we're getting non-existent layers, for now we're logging
	// them out and continue working
	if resp.StatusCode == http.StatusNotFound {
		klog.Warningf("Unable to prune layer %s, returned %v", url, resp.Status)
		return nil
	}

	// non-2xx/3xx response doesn't cause an error, so we need to check for it
	// manually and return it to caller
	if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {
		return fmt.Errorf(resp.Status)
	}

	if resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusAccepted {
		klog.V(1).Infof("Unexpected status code in response: %d", resp.StatusCode)
		var response errcode.Errors
		decoder := json.NewDecoder(resp.Body)
		if err := decoder.Decode(&response); err != nil {
			return err
		}
		klog.V(1).Infof("Response: %#v", response)
		return &response
	}

	return err
}
1232270
func (p *Plugin) Register(registryPath string, collector prometheus.Collector) error {
	p.Lock()
	defer p.Unlock()

	reg, found := p.regs[registryPath]
	if !found {
		p.Log.WithField("path", registryPath).Error(ErrRegistryNotFound)
		return ErrRegistryNotFound
	}
	return reg.Register(collector)
}
896354
func (ps *peerSet) Unregister(id string) error {
	ps.lock.Lock()
	if p, ok := ps.peers[id]; !ok {
		ps.lock.Unlock()
		return errNotRegistered
	} else {
		delete(ps.peers, id)
		peers := make([]peerSetNotify, len(ps.notifyList))
		copy(peers, ps.notifyList)
		ps.lock.Unlock()

		for _, n := range peers {
			n.unregisterPeer(p)
		}

		p.sendQueue.quit()
		p.Peer.Disconnect(p2p.DiscUselessPeer)

		return nil
	}
}
364860
func Register(pl plugin.Plugin) error {
	for _, p := range plugin.Plugins() {
		if p.String() == pl.String() {
			return fmt.Errorf("%s registered globally", pl.String())
		}
	}
	return defaultManager.Register(pl)
}
208803
func ReRegister(params ReRegisterParams) (*Identity, error) {
	hostID, err := params.ID.HostID()
	if err != nil {
		return nil, trace.Wrap(err)
	}
	keys, err := params.Client.GenerateServerKeys(GenerateServerKeysRequest{
		HostID:               hostID,
		NodeName:             params.ID.NodeName,
		Roles:                teleport.Roles{params.ID.Role},
		AdditionalPrincipals: params.AdditionalPrincipals,
		DNSNames:             params.DNSNames,
		PublicTLSKey:         params.PublicTLSKey,
		PublicSSHKey:         params.PublicSSHKey,
		Rotation:             &params.Rotation,
	})
	if err != nil {
		return nil, trace.Wrap(err)
	}
	keys.Key = params.PrivateKey

	return ReadIdentityFromKeyPair(keys)
}
114808
func (r *Registry) Unregister(c Collector) bool {
	var (
		descChan    = make(chan *Desc, capDescChan)
		descIDs     = map[uint64]struct{}{}
		collectorID uint64 // Just a sum of the desc IDs.
	)
	go func() {
		c.Describe(descChan)
		close(descChan)
	}()
	for desc := range descChan {
		if _, exists := descIDs[desc.id]; !exists {
			collectorID += desc.id
			descIDs[desc.id] = struct{}{}
		}
	}

	r.mtx.RLock()
	if _, exists := r.collectorsByID[collectorID]; !exists {
		r.mtx.RUnlock()
		return false
	}
	r.mtx.RUnlock()

	r.mtx.Lock()
	defer r.mtx.Unlock()

	delete(r.collectorsByID, collectorID)
	for id := range descIDs {
		delete(r.descIDs, id)
	}
	// dimHashesByName is left untouched as those must be consistent
	// throughout the lifetime of a program.
	return true
}
756395
func (r *Registry) Register(name string, v interface{}) interface{} {
	r.m.Lock()
	defer r.m.Unlock()
	switch v.(type) {
	case instruments.Discrete, instruments.Sample:
		i, present := r.instruments[name]
		if present {
			return i
		}
		r.instruments[name] = v
		return v
	}
	return nil
}
231676
func Unregister(name string) {
	if _, ok := factories[name]; !ok {
		log.Warningf("workflow %v doesn't exist, cannot remove it", name)
	} else {
		delete(factories, name)
	}
}
313869
func (c *Cluster) Unregister(address string) error {
	err := c.runHookForAddr(HookEventBeforeNodeUnregister, address)
	if err != nil {
		return err
	}
	return c.storage().RemoveNode(address)
}
67975
func (registry *pluginRegistry) RegisterUnique(plugin Plugin, ID string) bool {
	registry.guard.Lock()
	defer registry.guard.Unlock()

	if _, exists := registry.plugins[ID]; !exists {
		registry.plugins[ID] = plugin
		return true
	}

	return false
}
132802
func NewRegistry(name string, r func(...registry.Option) registry.Registry) Option {
	return func(o *Options) {
		o.Registries[name] = r
	}
}
587117
func (p *multiResourcePool) Unregister(resourceLocation string) error {
	p.rwMutex.Lock()
	defer p.rwMutex.Unlock()

	if pool, inMap := p.locationPools[resourceLocation]; inMap {
		_ = pool.Unregister("")
		pool.EnterLameDuckMode()
		delete(p.locationPools, resourceLocation)
	}
	return nil
}
323349
func (devices *DeviceSet) unregisterDevice(id int, hash string) error {
	logrus.Debugf("devmapper: unregisterDevice(%v, %v)", id, hash)
	info := &devInfo{
		Hash:     hash,
		DeviceID: id,
	}

	delete(devices.Devices, hash)

	if err := devices.removeMetadata(info); err != nil {
		logrus.Debugf("devmapper: Error removing metadata: %s", err)
		return err
	}

	return nil
}
1084511
func (l *MockLedger) Unregister(Consumer Consumer) {
	l.Lock()
	defer l.Unlock()

	for i, p := range l.consumers {
		if p == Consumer {
			if i != 0 {
				l.consumers = l.consumers[1:]
			}
			l.consumers = l.consumers[1:]
			break
		}
	}
}
28951
func handleUnregister(proxy *mist.Proxy, msg mist.Message) error {

	if err := defaultAuth.RemoveToken(msg.Data); err != nil {
		return err
	}

	return nil
}
273517
func (ref *EventClientRef) Unregister(reg fab.Registration) {
	if service, err := ref.get(); err != nil {
		logger.Warnf("Error unregistering event registration: %s", err)
	} else {
		service.Unregister(reg)
	}
}