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

Support blocking queries #366

Merged
merged 26 commits into from
Nov 4, 2015
Merged

Support blocking queries #366

merged 26 commits into from
Nov 4, 2015

Conversation

ryanuber
Copy link
Member

This adds blocking queries to all of the RPC endpoints. This transitively allows blocking queries to be supported by all of the HTTP endpoints, except the /v1/agent/* ones. All of the blocking queries are scoped to minimize waking clients when there is no data change, so for example a blocking query on /v1/node/node1/allocations will not fire if a new allocation is made on node2.

allocWatch: args.NodeID,
queryOpts: &args.QueryOptions,
queryMeta: &reply.QueryMeta,
watch: watch.NewItems(watch.Item{AllocNode: args.NodeID}),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if we would want to also watch the node entry here. It's possible to do that with the framework used here, but we would increase the frequency this watch would fire for potentially no change.

@armon
Copy link
Member

armon commented Oct 30, 2015

@ryanuber Wow, you went big! I'm wondering, is there any commonality between how we do it here, and Consul? I'm wondering if we can have a shared "watch" lib between the two. Potentially makes sense to add hooks into MemDB to support this as well.

Thoughts? /cc: @slackpad

@sethvargo
Copy link
Contributor

❤️

@ryanuber
Copy link
Member Author

There is definitely common functionality here which we can abstract and share between both Consul and Nomad. MemDB would be a good place to expose the low-level change notification, and we can just implement the delta watch triggering in each respective project we need it for! Sounds great to me, this will just be for 0.2 or until we find a good way of exposing the functionality in a way that's useful for the greater good.

@slackpad
Copy link
Contributor

Totally agree we could share this and MemDB seems like the right place. If MemDB handles table-level triggering with some data to inspect about what changed then the project-level stuff I think would be filtering and aggregation. Like MemDB calls a registered hook and gives you a list of keys added/removed or something like that. Would need to think on it a little more.

For Consul making the watches more granular would be the perfect time to do this.

I like how @ryanuber you've exposed some pretty low-level stuff up to the RPC call site to let the caller pick what they want. I kind of went back and forth on this and ended up having a mapping to state_store functions (kind of like the pre-MemDB code) but this way is probably better.

@dadgar
Copy link
Contributor

dadgar commented Nov 4, 2015

LGTM

ryanuber added a commit that referenced this pull request Nov 4, 2015
@ryanuber ryanuber merged commit 7f63be4 into master Nov 4, 2015
@ryanuber ryanuber deleted the f-blocking branch November 4, 2015 19:18
@github-actions
Copy link

github-actions bot commented May 6, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants