Skip to content
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

Merged
merged 1 commit into from
Feb 15, 2022
Merged

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Feb 14, 2022

Clarify the rules for implementing a query function passed to Server.blockingQuery. Related to #12109 and #12110

The 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 and structs.QueryMetaCompat since those are now only used by a few parse functions in http.go. By following the pattern used here we could replace that usage as well.

@dnephin dnephin added the pr/no-changelog PR does not need a corresponding .changelog entry label Feb 14, 2022
@dnephin dnephin requested a review from a team February 14, 2022 22:34
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 14, 2022 22:36 Inactive
@vercel vercel bot temporarily deployed to Preview – consul February 14, 2022 22:36 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 15, 2022 18:36 Inactive
@vercel vercel bot temporarily deployed to Preview – consul February 15, 2022 18:36 Inactive
Copy link
Contributor

@freddygv freddygv left a 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.

// 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
Copy link
Contributor

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:

Suggested change
// 2. it must set the responseMeta.GetIndex to an index greater than
// 2. it must set the responseMeta.Index to an index greater than

Copy link
Contributor Author

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.

// 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
Copy link
Contributor

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.
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging February 15, 2022 19:20 Inactive
@vercel vercel bot temporarily deployed to Preview – consul February 15, 2022 19:20 Inactive
@dnephin dnephin merged commit 09d61e6 into main Feb 15, 2022
@dnephin dnephin deleted the dnephin/blocking-query-docs branch February 15, 2022 19:50
@hc-github-team-consul-core
Copy link
Collaborator

🍒 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-changelog PR does not need a corresponding .changelog entry pr/no-metrics-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants