more work done
This commit is contained in:
parent
09fe1cd163
commit
6fda229a8e
23 changed files with 384 additions and 177 deletions
|
|
@ -5,13 +5,16 @@ import (
|
|||
"errors"
|
||||
"strings"
|
||||
|
||||
"git.giftfish.de/ston1th/vipman/pkg/cluster"
|
||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/cluster"
|
||||
//"go.etcd.io/etcd/clientv3"
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"github.com/go-logr/logr"
|
||||
)
|
||||
|
||||
var ErrKeyNotFound = errors.New("key not found")
|
||||
var (
|
||||
ErrKeyNotFound = errors.New("etcd: key not found")
|
||||
ErrPrefixNotFound = errors.New("etcd: prefix not found")
|
||||
)
|
||||
|
||||
type Cluster struct {
|
||||
logr.Logger
|
||||
|
|
@ -59,7 +62,7 @@ func (c *Cluster) GetPrefix(k string) (m map[string][]byte, err error) {
|
|||
return
|
||||
}
|
||||
if len(r.Kvs) == 0 {
|
||||
err = ErrKeyNotFound
|
||||
err = ErrPrefixNotFound
|
||||
return
|
||||
}
|
||||
m = make(map[string][]byte)
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.giftfish.de/ston1th/vipman/pkg/config"
|
||||
"git.giftfish.de/ston1th/vipman/pkg/util"
|
||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/config"
|
||||
"git.giftfish.de/ston1th/haproxy-lb/pkg/util"
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
|
@ -198,6 +198,11 @@ func (c *Cluster) Stepdown() {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) Fatal(err error, msg string) {
|
||||
c.Error(err, "a fatal error occurred", "message", msg)
|
||||
c.Stop()
|
||||
}
|
||||
|
||||
func (c *Cluster) Stop() {
|
||||
if !c.session {
|
||||
c.cancelSession()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue