func (h *HostCallbacks) Deleted(zkPath string) {
	logger.Debugf("HostCallbacks.Deleted(%s)", zkPath)
	hostName, poolName := h.splitPath(zkPath)
	if pool := h.config.Pools[poolName]; pool != nil {
		pool.DelServer(hostName)
	}
}
func (p *RuleCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("RuleCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	var rule config.Rule
	if err := json.Unmarshal([]byte(jsonBlob), &rule); err != nil {
		logger.Errorf("%s unmarshalling %s as rule", err.Error(), jsonBlob)
		return
	}
	p.config.AddRule(rule)
}
func (p *PortCallbacks) Changed(zkPath, jsonBlob string) {
	logger.Debugf("PortCallbacks.Changed(%s)", zkPath, jsonBlob)
	var port config.Port
	if err := json.Unmarshal([]byte(jsonBlob), &port); err != nil {
		logger.Errorf("%s unmarshalling %s as port", err.Error(), jsonBlob)
		return
	}
	p.config.UpdatePort(port)
}
func (p *PoolCallbacks) Changed(path, jsonBlob string) {
	logger.Debugf("PoolCallbacks.Changed(%s, %s)", path, jsonBlob)
	var zkPool zk.ZkPool
	if err := json.Unmarshal([]byte(jsonBlob), &zkPool); err != nil {
		logger.Errorf("%s unmarshalling %s as pool", err.Error(), jsonBlob)
		return
	}
	p.config.UpdatePool(zkPool.Pool(nil))
}
func (p *PoolCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("PoolCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	var zkPool zk.ZkPool
	if err := json.Unmarshal([]byte(jsonBlob), &zkPool); err != nil {
		logger.Errorf("%s unmarshalling %s as pool", err.Error(), jsonBlob)
		return
	}
	p.config.AddPool(zkPool.Pool(map[string]config.Host{}))
}
func (p *TrieCallbacks) Changed(path, jsonBlob string) {
	logger.Debugf("TrieCallbacks.Changed(%s, %s)", path, jsonBlob)
	var trie config.Trie
	if err := json.Unmarshal([]byte(jsonBlob), &trie); err != nil {
		logger.Errorf("%s unmarshalling %s as trie", err.Error(), jsonBlob)
		return
	}
	p.config.UpdateTrie(trie)
}
func (p *PortCallbacks) Deleted(zkPath string) {
	logger.Debugf("PortCallbacks.Deleted(%s)", zkPath)
	port, err := strconv.ParseUint(path.Base(zkPath), 10, 16)
	if err != nil {
		logger.Errorf("%s interpreting base of %s as uint16", err.Error(), zkPath)
		return
	}
	p.config.DelPort(uint16(port))
	p.router.DelPort(uint16(port))
}
func (p *TrieCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("TrieCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	var trie config.Trie
	err := json.Unmarshal([]byte(jsonBlob), &trie)
	if err != nil {
		logger.Errorf("%s unmarshalling %s as trie", err.Error(), jsonBlob)
		return
	}
	p.config.AddTrie(trie)
}
Exemple #9
0
func (p *Pool) RunChecks() {
	for {
		select {
		case <-time.After(p.Config.HealthzEvery):
			for _, server := range p.Servers {
				go server.CheckStatus(p.Config.HealthzTimeout)
			}
		case <-p.killCh:
			logger.Debugf("[pool %s] stopping checks", p.Name)
			return
		}
	}
}
func (h *HostCallbacks) Created(zkPath, jsonBlob string) {
	logger.Debugf("HostCallbacks.Created(%s, %s)", zkPath, jsonBlob)
	hostName, poolName := h.splitPath(zkPath)

	var host config.Host
	if err := json.Unmarshal([]byte(jsonBlob), &host); err != nil {
		logger.Errorf("%s unmarshalling %s as host", err.Error(), jsonBlob)
		return
	}

	if pool := h.config.Pools[poolName]; pool != nil {
		pool.AddServer(hostName, h.config.ConstructServer(host))
	}
}
func (p *PoolCallbacks) Deleted(zkPath string) {
	logger.Debugf("PoolCallbacks.Deleted(%s)", zkPath)
	p.config.DelPool(path.Base(zkPath))
}
func (p *TrieCallbacks) Deleted(zkPath string) {
	logger.Debugf("TrieCallbacks.Deleted(%s)", zkPath)
	p.config.DelTrie(path.Base(zkPath))
}