added raft over tls

This commit is contained in:
ston1th 2020-11-15 00:30:35 +01:00
commit 585baea183
16 changed files with 563 additions and 300 deletions

36
pkg/raft/cluster.go Normal file
View file

@ -0,0 +1,36 @@
package raft
import (
"errors"
"git.giftfish.de/ston1th/vipman/pkg/cluster"
"github.com/hashicorp/raft"
)
type Cluster struct {
kv *KV
r *raft.Raft
stepdown chan struct{}
stop chan struct{}
done chan struct{}
Callbacks cluster.Callbacks
}
func NewCluster(callbacks cluster.Callbacks) (cluster.Cluster, error) {
if callbacks.Leader == nil {
return nil, errors.New("Leader is nil")
}
if callbacks.Follower == nil {
return nil, errors.New("Follower is nil")
}
return &Cluster{
kv: &KV{
m: make(map[string][]byte),
},
stepdown: make(chan struct{}, 1),
stop: make(chan struct{}, 1),
done: make(chan struct{}, 1),
Callbacks: callbacks,
}, nil
}