Skip to content

feat: add pagination to ListPeers and ListHosts - #701

Merged
gaius-qi merged 1 commit into
mainfrom
feature/list-peers-pagination
Nov 18, 2026
Merged

gaius-qi merged 1 commit into
mainfrom
feature/list-peers-pagination

Conversation

@chlins

@chlins chlins commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Description

Add page_size and page_token to ListPeersRequest and ListHostsRequest, and next_page_token to ListPeersResponse and ListHostsResponse.

  • If page_size is not specified, all the items are returned, the same as today. A negative value is rejected.
  • next_page_token is sent back as page_token to get the next page. It is not set when there are no more pages.
  • The fields are 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

ListPeers and ListHosts return 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. ListHosts keeps returning all the hosts when page_size is not set, because the request sdk builds its seed peer hashring from the full list.

@chlins
chlins requested review from a team as code owners November 18, 2026 07:01
@chlins
chlins force-pushed the feature/list-peers-pagination branch from 17b4444 to 3ee2331 Compare November 18, 2026 07:13
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
chlins force-pushed the feature/list-peers-pagination branch from 3ee2331 to 35e7eba Compare November 18, 2026 07:20
@chlins chlins changed the title feat: add pagination to ListPeers feat: add pagination to ListPeers and ListHosts Nov 18, 2026

@gaius-qi gaius-qi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@gaius-qi
gaius-qi enabled auto-merge (squash) November 18, 2026 07:30
@gaius-qi
gaius-qi disabled auto-merge November 18, 2026 07:30
@gaius-qi
gaius-qi merged commit 052bba3 into main Nov 18, 2026
6 checks passed
@gaius-qi
gaius-qi deleted the feature/list-peers-pagination branch November 18, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants