added etcd support

This commit is contained in:
ston1th 2020-11-15 18:39:16 +01:00
commit 85a8ba23bd
21 changed files with 767 additions and 247 deletions

View file

@ -27,7 +27,7 @@ type raftCmd struct {
V []byte
}
type fsm KV
type fsm kv
func (f *fsm) Apply(l *raft.Log) interface{} {
var c raftCmd
@ -49,7 +49,7 @@ func (f *fsm) Apply(l *raft.Log) interface{} {
func (f *fsm) Snapshot() (raft.FSMSnapshot, error) {
f.mu.Lock()
defer f.mu.Unlock()
m := make(kv)
m := make(kvm)
for k, v := range f.m {
m[k] = v
}
@ -57,7 +57,7 @@ func (f *fsm) Snapshot() (raft.FSMSnapshot, error) {
}
func (f *fsm) Restore(rc io.ReadCloser) error {
o := make(kv)
o := make(kvm)
if err := msgpack.NewDecoder(rc).Decode(&o); err != nil {
return err
}
@ -78,7 +78,7 @@ func (f *fsm) applyDelete(k string) {
}
type fsmSnapshot struct {
m kv
m kvm
}
func (f *fsmSnapshot) Persist(sink raft.SnapshotSink) error {