control: fix Consul linearizable read

This commit is contained in:
Gyu-Ho Lee 2016-11-15 19:03:07 -08:00
parent b86b1cc1ac
commit 5cb2b9c74d
No known key found for this signature in database
GPG Key ID: 1DDD39C7EB70C24C
1 changed files with 7 additions and 1 deletions

View File

@ -107,7 +107,13 @@ func newGetZK(conn *zk.Conn) ReqHandler {
func newGetConsul(conn *consulapi.KV) ReqHandler { func newGetConsul(conn *consulapi.KV) ReqHandler {
return func(ctx context.Context, req *request) error { return func(ctx context.Context, req *request) error {
_, _, err := conn.Get(req.consulOp.key, &consulapi.QueryOptions{AllowStale: req.consulOp.staleRead}) opt := &consulapi.QueryOptions{
AllowStale: req.consulOp.staleRead,
}
if !req.consulOp.staleRead {
opt.RequireConsistent = true
}
_, _, err := conn.Get(req.consulOp.key, opt)
return err return err
} }
} }