pbd client: adds nodes pagination cursor #82
Merged
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.
To make iterating over pages of nodes easier and consistent, I added a pagination cursor that allows a user of the nodes client to call NodesCursor.Next() to keep fetching pages until an io.EOF error is returned. This keeps the client use minimal of implementing packages (such as scarp) and centralizes and hides the pagination state/logic so it doesn't need to be implemented over and over again.
I think we should generalize this a bit more and add it to all the pdb calls we export in this package as clients. I'm not sure if we can generalize it for the entire go-pe-client tree because other pagination schemes across PE might be different than pdb's API.