v3rpc: force RangeEnd=nil if length is 0

gRPC will replace empty strings with nil, but for the embedded case it's
possible for []byte{} to slip in and confuse the single key / >= key
watch logic.
This commit is contained in:
Anthony Romano 2017-03-30 18:13:24 -07:00
parent 4b4f5be74a
commit 135a40751e

View File

@ -171,6 +171,11 @@ func (sws *serverWatchStream) recvLoop() error {
// \x00 is the smallest key
creq.Key = []byte{0}
}
if len(creq.RangeEnd) == 0 {
// force nil since watchstream.Watch distinguishes
// between nil and []byte{} for single key / >=
creq.RangeEnd = nil
}
if len(creq.RangeEnd) == 1 && creq.RangeEnd[0] == 0 {
// support >= key queries
creq.RangeEnd = []byte{}