mirror of
https://github.com/gravitational/teleport.git
synced 2026-11-02 06:08:23 +08:00
Incorrectly paging through resource lists has been a common source of bugs in Teleport. This patch adds some types we can use to make that process less error prone. The most common issue is recycling page tokens, so listing a resource becomes an infinite loop. This patch introduced the PageRequestToken, which wraps a token value and ensures that it is used at most once. Attempting to recycle a token value without updating it returns an error, making iteration bugs more obvious. It also has a strongly typed NextPageToken that can be returned by paginated listings. This both ensures that attempting to assign the wrong token value to the wrong token type becomes a compile-time error. Example usage is in the package godoc.