consul: Adding a method to enforce consistent read

This commit is contained in:
Armon Dadgar 2014-04-18 17:49:01 -07:00
parent dbdfcbc717
commit f7bcffe627
1 changed files with 8 additions and 0 deletions

View File

@ -264,3 +264,11 @@ func (s *Server) setQueryMeta(m *structs.QueryMeta) {
m.KnownLeader = (s.raft.Leader() != nil)
}
}
// consistentRead is used to ensure we do not perform a stale
// read. This is done by verifying leadership before the read.
func (s *Server) consistentRead() error {
defer metrics.MeasureSince([]string{"consul", "rpc", "consistentRead"}, time.Now())
future := s.raft.VerifyLeader()
return future.Error()
}