added raft over tls
This commit is contained in:
parent
b0d13076e0
commit
585baea183
16 changed files with 563 additions and 300 deletions
36
pkg/raft/cluster.go
Normal file
36
pkg/raft/cluster.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue