new logger and etcd fixes

This commit is contained in:
ston1th 2021-10-09 16:52:06 +02:00
commit cbd4f38cca
11 changed files with 248 additions and 161 deletions

View file

@ -11,7 +11,7 @@ import (
)
type Cluster struct {
logr.Logger
log logr.Logger
cli *clientv3.Client
ctx context.Context
@ -24,18 +24,23 @@ type Cluster struct {
id string
keyID string
session bool
cancelSession func()
sessionCancel func()
fatal error
}
func NewCluster(log logr.Logger) cluster.Cluster {
return &Cluster{
Logger: log,
ctx: context.Background(),
stepdown: make(chan struct{}, 1),
stop: make(chan struct{}, 1),
done: make(chan struct{}, 1),
}
c := &Cluster{log: log}
c.Reset()
return c
}
func (c *Cluster) Reset() {
c.ctx = context.Background()
c.stepdown = make(chan struct{}, 1)
c.stop = make(chan struct{}, 1)
c.done = make(chan struct{}, 1)
c.session = false
c.fatal = nil
}
func (c *Cluster) Get(k string) (v []byte, err error) {
@ -83,6 +88,10 @@ func (c *Cluster) SetCallbacks(callbacks cluster.Callbacks) error {
return c.checkConfig()
}
func (c *Cluster) Logger() logr.Logger {
return c.log
}
func (c *Cluster) ID() string {
return c.id
}