Пример #1
0
func (p *brokerPool) addAddr(addr string) *broker.B {
	if broker, ok := p.addrBroker[addr]; ok {
		return broker
	}
	broker := p.newBroker(addr)
	p.addrBroker[addr] = broker
	log.Debugf("broker %s added to pool", addr)
	return broker
}
Пример #2
0
func (p *brokerPool) find(brokerID int32) (*broker.B, error) {
	if addr, ok := p.idAddr[brokerID]; ok {
		if broker, ok := p.addrBroker[addr]; ok {
			return broker, nil
		}
	}
	log.Debugf("cannot find broker %d", brokerID)
	return nil, ErrNoBrokerFound
}