1
0
Fork 0

Wait until Leader Commit is at least 1

master
Philip O'Toole 7 months ago
parent 53e0666c9e
commit a48f48e55a

@ -635,12 +635,16 @@ func (s *Store) Ready() bool {
// Committed blocks until the local commit index is greater than or
// equal to the Leader index, as checked when the function is called.
// It returns the committed index.
// It returns the committed index. If the Leader index is 0, then the
// system waits until the commit index is at least 1.
func (s *Store) Committed(timeout time.Duration) (uint64, error) {
lci, err := s.LeaderCommitIndex()
if err != nil {
return lci, err
}
if lci == 0 {
lci = 1
}
return lci, s.WaitForCommitIndex(lci, timeout)
}

Loading…
Cancel
Save