Repository navigation
feat: add pagination to ListPeers and ListHosts - #701
Merged
Merged
Conversation
chlins
requested review from
BruceAko,
ClementMaH,
fcgxz2003,
gaius-qi,
xujihui1985 and
yyzai384
November 18, 2026 07:01
chlins
force-pushed
the
feature/list-peers-pagination
branch
from
November 18, 2026 07:13
17b4444 to
3ee2331
Compare
Add page_size and page_token to ListPeersRequest and ListHostsRequest, and next_page_token to ListPeersResponse and ListHostsResponse, so the caller can list the peers and the hosts page by page instead of getting all of them in one message. If page_size is not specified, all the items are returned as before. The next page token is not set when there are no subsequent pages. Related to dragonflyoss/dragonfly#5116. Signed-off-by: Chlins Zhang <chlins.zhang@gmail.com>
chlins
force-pushed
the
feature/list-peers-pagination
branch
from
November 18, 2026 07:20
3ee2331 to
35e7eba
Compare
gaius-qi
enabled auto-merge (squash)
November 18, 2026 07:30
gaius-qi
disabled auto-merge
November 18, 2026 07:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add
page_sizeandpage_tokentoListPeersRequestandListHostsRequest, andnext_page_tokentoListPeersResponseandListHostsResponse.page_sizeis not specified, all the items are returned, the same as today. A negative value is rejected.next_page_tokenis sent back aspage_tokento get the next page. It is not set when there are no more pages.optional, like the other optional fields in this api.The fields are new, so the change is wire compatible with 2.3.11. Regenerate the Go, Rust and Python bindings and bump the version to 2.3.12.
References: listing in chunks with a continue token, and returning everything when no limit is given, is how the Kubernetes API handles large lists (https://kubernetes.io/docs/reference/using-api/api-concepts/#retrieving-large-results-sets-in-chunks). The field names follow AIP-158 (https://google.aip.dev/158).
Related Issue
dragonflyoss/dragonfly#5116
Motivation and Context
ListPeersandListHostsreturn everything in one message. A task can have thousands of peers and a scheduler can hold far more, about 1.3 KB each. With these fields a caller can ask for a few items or go through all of them page by page.ListHostskeeps returning all the hosts whenpage_sizeis not set, because the request sdk builds its seed peer hashring from the full list.