-
Notifications
You must be signed in to change notification settings - Fork 21
Implement proper pagination for list-payments cli #84
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
base: main
Are you sure you want to change the base?
Implement proper pagination for list-payments cli #84
Conversation
|
I've assigned @tankyleo as a reviewer! |
| if payments.len() >= target_count as usize || response.next_page_token.is_none() { | ||
| next_page_token = response.next_page_token; | ||
|
|
||
| if payments.len() >= target_count as usize || next_page_token.is_none() { |
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.
The point of surfacing the next_page_token back to the user is so that they can continue iterating after we've already satisfied their request to provide at least n payments ?
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.
Yes
| #[arg(long)] | ||
| #[arg(help = "Page token value to continue from a previous page")] | ||
| page_token_value: Option<String>, | ||
| #[arg(long)] | ||
| #[arg(help = "Page token index to continue from a previous page")] | ||
| page_token_index: Option<i64>, |
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.
Any chance we can make these into a single argument to eliminate footguns ? As long as we can display the PageToken as a single object that they can directly copy into the single argument here.
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.
Yeah that's a good call out. Will need #78 first so we can have custom cli output types for this
| if page_token_value.is_some() != page_token_index.is_some() { | ||
| return Err(LdkServerError::new( | ||
| InternalError, | ||
| "Both --page-token-value and --page-token-index must be provided together".to_string(), | ||
| )); | ||
| } |
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.
Single argument eliminates the possibility of this error here
Another thing in the backend but not the cli