added etcd kv

This commit is contained in:
ston1th 2020-11-15 22:02:23 +01:00
commit fd9f8fc1fd
8 changed files with 54 additions and 71 deletions

View file

@ -66,47 +66,7 @@ func main() {
sigs := make(chan os.Signal)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
<-sigs
log.Info("stopping vipman")
log.Info("vipman shutdown")
c.Stop()
//DeleteIPs(n, cfg.VirtualIPs)
log.Info("vipman stopped")
}
/*
c, err := raft.NewCluster(cluster.Callbacks{
Leader: func(ctx context.Context, kv cluster.KV) {
ticker := time.NewTicker(time.Second * 10)
for {
s := kv.Get("state")
if s == nil {
s = []byte{0}
} else {
s[0] = s[0] + 1
}
kv.Set("state", s)
s = kv.Get("state")
klog.Infof("[%s] l state: %d", cfg.LocalPeer.ID, s[0])
select {
case <-ctx.Done():
klog.Infof("[%s] leading canceled", cfg.LocalPeer.ID)
return
case <-ticker.C:
}
}
},
Follower: func(ctx context.Context, kv cluster.KV) {
ticker := time.NewTicker(time.Second * 2)
for {
s := kv.Get("state")
if s != nil {
klog.Infof("[%s] f state: %d", cfg.LocalPeer.ID, s[0])
}
select {
case <-ctx.Done():
klog.Infof("[%s] following canceled", cfg.LocalPeer.ID)
return
case <-ticker.C:
}
}
},
})
*/