Merge pull request #10496 from trung/raft-example
raftexample: added build instruction and minor refactoringrelease-3.4
commit
a7e3bd06b2
|
@ -6,6 +6,16 @@ raftexample is an example usage of etcd's [raft library](../../raft). It provide
|
|||
|
||||
## Getting Started
|
||||
|
||||
### Building raftexample
|
||||
|
||||
Clone `etcd` to `<directory>/src/go.etcd.io/etcd`
|
||||
|
||||
```sh
|
||||
export GOPATH=<directory>
|
||||
cd <directory>/src/go.etcd.io/etcd/contrib/raftexample
|
||||
go build -o raftexample
|
||||
```
|
||||
|
||||
### Running single node raftexample
|
||||
|
||||
First start a single-member cluster of raftexample:
|
||||
|
|
|
@ -48,8 +48,8 @@ func newKVStore(snapshotter *snap.Snapshotter, proposeC chan<- string, commitC <
|
|||
|
||||
func (s *kvstore) Lookup(key string) (string, bool) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
v, ok := s.kvStore[key]
|
||||
s.mu.RUnlock()
|
||||
return v, ok
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ func (s *kvstore) recoverFromSnapshot(snapshot []byte) error {
|
|||
return err
|
||||
}
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.kvStore = store
|
||||
s.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue