-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpc: improve docs for blockingQuery #12343
Conversation
427513d
to
a4f8028
Compare
a4f8028
to
a5de2b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for documenting this.
I left a minor suggestion below.
agent/consul/rpc.go
Outdated
// The query function must follow these rules: | ||
// | ||
// 1. to access data it must use the passed in state.Store. | ||
// 2. it must set the responseMeta.GetIndex to an index greater than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be clearer to reference the field name that gets updated:
// 2. it must set the responseMeta.GetIndex to an index greater than | |
// 2. it must set the responseMeta.Index to an index greater than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, I think this reads better. It's slightly less precise since technically we don't know what the field name is in the interface, but hopefully the reader understands the implication.
agent/consul/rpc.go
Outdated
// To ensure optimal performance of the query, the query function should make a | ||
// best-effort attempt to follow these guidelines: | ||
// | ||
// 1. only set responseMeta.GetIndex to an index greater than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
Follow the Go convention of accepting a small interface that documents the methods used by the function. Clarify the rules for implementing a query function passed to blockingQuery.
a5de2b8
to
3301f94
Compare
🍒 If backport labels were added before merging, cherry-picking will start automatically. To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/585305. |
Clarify the rules for implementing a query function passed to
Server.blockingQuery
. Related to #12109 and #12110The new interfaces here are to follow the Go convention of accepting a small interface that documents the methods used by the function. They help document the function by being explicit about which methods are used.
In the future we can probably removes
structs.QueryOptionsCompat
andstructs.QueryMetaCompat
since those are now only used by a few parse functions inhttp.go
. By following the pattern used here we could replace that usage as well.