示例#1
0
func (t *traefik) DeleteServer(ba loadbalancer.Backend, srv loadbalancer.Server) error {
	logger.Debugf("[%v] Attempting delete: %v", ba.GetID(), srv)
	key := path.Join(t.prefix, "backends", ba.GetID(), "servers", srv.GetID())
	if er := t.Exists(key); er != nil {
		return fmt.Errorf("Lookup %v failed: %v", srv, er)
	}

	return t.Delete(key)
}
示例#2
0
func (t *traefik) UpsertServer(ba loadbalancer.Backend, srv loadbalancer.Server) error {
	if er := t.Exists(path.Join(t.prefix, "backends", ba.GetID())); er != nil {
		return fmt.Errorf("Lookup %v failed: %v", ba, er)
	}

	urlKey := path.Join(t.prefix, "backends", ba.GetID(), "servers", srv.GetID(), "url")
	weightKey := path.Join(t.prefix, "backends", ba.GetID(), "servers", srv.GetID(), "weight")
	if er := t.Set(urlKey, srv.(*server).URL); er != nil {
		return er
	}
	weight := strconv.Itoa(srv.(*server).Weight)
	if er := t.Set(weightKey, weight); er != nil {
		return er
	}
	return nil
}
示例#3
0
func (t *traefik) DeleteBackend(ba loadbalancer.Backend) error {
	logger.Debugf("[%v] Attempting delete: %v", ba.GetID(), ba)
	key := path.Join(t.prefix, "backends", ba.GetID())
	return t.Delete(key)
}
示例#4
0
func (t *traefik) UpsertBackend(ba loadbalancer.Backend) error {
	b, ok := ba.(*backend)
	if !ok {
		return fmt.Errorf("Not of expected type: %v", ba)
	}

	pre := path.Join(t.prefix, "backends", ba.GetID())
	if b.CircuitBreaker != nil && b.CircuitBreaker.Expression != "" {
		if er := t.Set(path.Join(pre, cb), b.CircuitBreaker.Expression); er != nil {
			logger.Warnf("[%v] Upsert %s error: %v", ba.GetID(), cb, er)
		}
	}
	if b.LoadBalancer != nil && b.LoadBalancer.Method != "" {
		if er := t.Set(path.Join(pre, lb), b.LoadBalancer.Method); er != nil {
			logger.Warnf("[%v] Upsert %s error: %v", ba.GetID(), lb, er)
		}
	}

	for id, srv := range b.Servers {
		logger.Debugf("[%v] Upserting Server(%v)", ba.GetID(), srv.URL)
		urlK := path.Join(pre, "servers", id, "url")
		weightK := path.Join(pre, "servers", id, "weight")
		if er := t.Set(urlK, srv.URL); er != nil {
			logger.Warnf("[%v] Upsert error: %v", ba.GetID(), er)
		}
		weight := strconv.Itoa(srv.Weight)
		if er := t.Set(weightK, weight); er != nil {
			logger.Warnf("[%v] Upsert error: %v", ba.GetID(), er)
		}
	}
	return nil
}
示例#5
0
func (v *vulcan) DeleteServer(ba loadbalancer.Backend, srv loadbalancer.Server) error {
	return v.Client.DeleteServer(
		engine.ServerKey{BackendKey: engine.BackendKey{Id: ba.GetID()}, Id: srv.GetID()},
	)
}
示例#6
0
func (v *vulcan) DeleteBackend(ba loadbalancer.Backend) error {
	return v.Client.DeleteBackend(engine.BackendKey{Id: ba.GetID()})
}
示例#7
0
func (v *vulcan) UpsertServer(backend loadbalancer.Backend, srv loadbalancer.Server) error {
	return v.Client.UpsertServer(engine.BackendKey{Id: backend.GetID()}, srv.(*server).Server, 0)
}