// AddRemoteBindingListener adds a listener
190464
func (r *RemoteService) AddRemoteBindingListener(bindingListener cluster.RemoteBindingListener) {
	r.remoteBindingListeners = append(r.remoteBindingListeners, bindingListener)
}
1163620
func (b *eventListenerSupport) addListener(substr string, listener chan string) {
	b.Lock()
	defer b.Unlock()
	if listeners, ok := b.listeners[substr]; ok {
		b.listeners[substr] = append(listeners, listener)
	} else {
		b.listeners[substr] = []chan string{listener}
	}
}
846817
func (state *ServicesState) AddListener(listener Listener) {
	if listener.Chan() == nil {
		log.Errorf("Refusing to add listener %s with nil channel!", listener.Name())
		return
	}

	if cap(listener.Chan()) < 1 {
		log.Errorf("Refusing to add blocking channel as listener: %s", listener.Name())
		return
	}
	state.Lock()
	defer state.Unlock()

	state.listeners[listener.Name()] = listener
	log.Debugf("AddListener(): added %s, new count %d", listener.Name(), len(state.listeners))
}
1233753
func (m *Manager) BindRemote(ctx context.Context, addrs RemoteAddrs) error {
	m.addrMu.Lock()
	defer m.addrMu.Unlock()

	if m.config.RemoteAPI != nil {
		return errors.New("manager already has remote API address")
	}

	// If an AdvertiseAddr was specified, we use that as our
	// externally-reachable address.
	advertiseAddr := addrs.AdvertiseAddr

	var advertiseAddrPort string
	if advertiseAddr == "" {
		// Otherwise, we know we are joining an existing swarm. Use a
		// wildcard address to trigger remote autodetection of our
		// address.
		var err error
		_, advertiseAddrPort, err = net.SplitHostPort(addrs.ListenAddr)
		if err != nil {
			return fmt.Errorf("missing or invalid listen address %s", addrs.ListenAddr)
		}

		// Even with an IPv6 listening address, it's okay to use
		// 0.0.0.0 here. Any "unspecified" (wildcard) IP will
		// be substituted with the actual source address.
		advertiseAddr = net.JoinHostPort("0.0.0.0", advertiseAddrPort)
	}

	l, err := net.Listen("tcp", addrs.ListenAddr)
	if err != nil {
		return errors.Wrap(err, "failed to listen on remote API address")
	}
	if advertiseAddrPort == "0" {
		advertiseAddr = l.Addr().String()
		addrs.ListenAddr = advertiseAddr
	}

	m.config.RemoteAPI = &addrs

	m.raftNode.SetAddr(ctx, advertiseAddr)
	m.remoteListener <- l

	return nil
}
29329
func (m *MultiplexedListener) RegisterDefaultListener(p *ProtoListener) error {
	m.Lock()
	defer m.Unlock()

	if m.defaultListener != nil {
		return fmt.Errorf("Default listener already registered")
	}

	m.defaultListener = p
	return nil
}
362850
func (c *Client) Listener(kind ListenerType, event string) *Listener {
	listener := &Listener{
		Type:      kind,
		Event:     event,
		Messages:  make(chan redis.Message),
		PMessages: make(chan redis.PMessage),
		Client:    c,
	}
	c.Subscribe(listener)

	return listener
}
664923
func NewListenerOrDefault(proto, defaultBindAddress string) (net.Listener, error) {
	l, err := NewListener()
	if err == nil {
		return l, nil
	}

	dl, err := net.Listen(proto, defaultBindAddress)
	if err == nil {
		return dl, nil
	}
	return nil, err
}
646100
func (es *EventStream) AddReceiver(w http.ResponseWriter) (*EventReceiver, error) {
	w.Header().Set("Content-Type", "text/event-stream")
	w.Header().Set("Cache-Control", "no-cache")
	w.Header().Set("Connection", "keep-alive")

	w.WriteHeader(200)

	hj, ok := w.(http.Hijacker)
	if !ok {
		return nil, ErrUnableToHijackRequest
	}

	hjConn, hjBufrw, err := hj.Hijack()
	if err != nil {
		return nil, err
	}

	rec := &EventReceiver{es, hjConn, hjBufrw}

	es.mutex.Lock()
	es.receivers[hjConn] = rec
	es.mutex.Unlock()

	return rec, nil
}
764462
func NewListener() (net.Listener, error) {
	portmap, err := Ports()
	if err != nil {
		return nil, err
	}
	return NewListenerOn(portmap[0])
}
1338384
func (g *Git) AddRemote(ctx context.Context, remote, url string) error {
	return g.Cmd(ctx, "gitAddRemote", "remote", "add", remote, url)
}
682172
func (t *MockSocket) AddReceivedMessage(response string) {
	t.receivedMessages <- json.RawMessage(response)
}
808774
func MakeListener(addr, ts string, conf *tls.Config) (net.Listener, error) {

	var l net.Listener
	var err error

	if conf != nil {
		l, err = tls.Listen(ts, addr, conf)
	} else {
		l, err = net.Listen(ts, addr)
	}

	if err != nil {
		return nil, err
	}

	return l, nil
}
133987
func (hc *HealthCheckImpl) SetListener(listener HealthCheckStatsListener, sendDownEvents bool) {
	if hc.listener != nil {
		panic("must not call SetListener twice")
	}

	hc.mu.Lock()
	defer hc.mu.Unlock()
	if len(hc.addrToHealth) > 0 {
		panic("must not call SetListener after tablets were added")
	}

	hc.listener = listener
	hc.sendDownEvents = sendDownEvents
}
107761
func (s *CreateListenerOutput) SetListener(v *Listener) *CreateListenerOutput {
	s.Listener = v
	return s
}
378302
func AddStatusListener(listener StatusListener) {
	statusListeners.Lock()
	statusListeners.s = append(statusListeners.s, listener)
	statusListeners.Unlock()
}
460860
func NewListenersOn(list []ListenTarget) ([]net.Listener, error) {
	ret := []net.Listener{}
	for _, t := range list {
		l, err := NewListenerOn(t)
		if err != nil {
			return nil, err
		}
		ret = append(ret, l)
	}
	return ret, nil
}
1120375
func (s *CreateRuleInput) SetListenerArn(v string) *CreateRuleInput {
	s.ListenerArn = &v
	return s
}