Merge pull request #12389 from hashicorp/dnephin/rpc-blocking-queries-not-found-nil

rpc: set response to nil when not found
pull/11138/head
Daniel Nephin 3 years ago committed by GitHub
commit 96029bb2bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -205,12 +205,10 @@ func (c *ConfigEntry) Get(args *structs.ConfigEntryQuery, reply *structs.ConfigE
return err return err
} }
reply.Index = index reply.Index, reply.Entry = index, entry
if entry == nil { if entry == nil {
return errNotFound return errNotFound
} }
reply.Entry = entry
return nil return nil
}) })
} }

@ -122,12 +122,10 @@ func (c *FederationState) Get(args *structs.FederationStateQuery, reply *structs
return err return err
} }
reply.Index = index reply.Index, reply.State = index, fedState
if fedState == nil { if fedState == nil {
return errNotFound return errNotFound
} }
reply.State = fedState
return nil return nil
}) })
} }

@ -945,7 +945,17 @@ type blockingQueryResponseMeta interface {
// //
// The query function is expected to be a closure that has access to responseMeta // The query function is expected to be a closure that has access to responseMeta
// so that it can set the Index. The actual result of the query is opaque to blockingQuery. // so that it can set the Index. The actual result of the query is opaque to blockingQuery.
// If query function returns an error, the error is returned to the caller immediately. //
// The query function can return errNotFound, which is a sentinel error. Returning
// errNotFound indicates that the query found no results, which allows
// blockingQuery to keep blocking until the query returns a non-nil error.
// The query function must take care to set the actual result of the query to
// nil in these cases, otherwise when blockingQuery times out it may return
// a previous result. errNotFound will never be returned to the caller, it is
// converted to nil before returning.
//
// If query function returns any other error, the error is returned to the caller
// immediately.
// //
// The query function must follow these rules: // The query function must follow these rules:
// //

Loading…
Cancel
Save