-
Notifications
You must be signed in to change notification settings - Fork 662
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
Auto pagination #596
Auto pagination #596
Conversation
Codecov Report
@@ Coverage Diff @@
## master #596 +/- ##
==========================================
+ Coverage 86.83% 88.26% +1.43%
==========================================
Files 6 7 +1
Lines 281 409 +128
Branches 44 70 +26
==========================================
+ Hits 244 361 +117
- Misses 26 31 +5
- Partials 11 17 +6
Continue to review full report at Codecov.
|
"url-join": "^4.0.0", | ||
"ws": "^5.2.0" | ||
}, | ||
"devDependencies": { | ||
"@aoberoi/capture-console": "^1.0.0", |
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.
😎
src/logger.ts
Outdated
@@ -79,7 +81,13 @@ log.methodFactory = function ( | |||
* INTERNAL interface for getting or creating a named Logger | |||
*/ | |||
// TODO: implement logger name prefixing (example plugins available on the loglevel package's site) | |||
export const getLogger = log.getLogger as (name: string) => Logger; | |||
// export const getLogger = log.getLogger as (name: string) => Logger; |
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.
Should this be deleted?
export async function awaitAndReduce<T, U>(iterable: AsyncIterable<T>, | ||
callbackfn: (previousValue: U, currentValue: T) => U, | ||
initialValue: U): Promise<U> { | ||
// TODO: make initialValue optional (overloads or conditional types?) |
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.
🤔
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.
meh, i think i'll leave that comment in there.
right now we don't need a version of this function that doesn't take an initialValue
because i'm manually passing {} as WebAPICallResult
into it. but, since this lives in util.ts
, it would be more reusable if it didn't need an initial value, the way that Array.prototype.reduce also doesn't require an initial value.
Summary
The platform is expanding the set of methods which support the shiniest of our pagination specifications, cursor-based pagination!
This change allows apps who previously made API calls to methods (that support cursor pagination) without any explicit pagination arguments to transparently traverse pages. This solves two major problems:
limit
values) in situations where the client didn't provide pagination arguments. This would create a subtle bug, but now these apps should get the entire list.This change also helps apps prepare for a future where pagination becomes mandatory in certain situations.
Fixes #343
Please review and provide feedback
At this point, my biggest concern is that this is a lot of new code, for what amounts to functionality we still strongly recommend developers do not use. More specifically, we still want developers to paginate requests themselves, and not to depend on the automatic pagination. Our reason is that this will result in more performant and optimized code. So, planting all this code is very intentionally a band-aid. My proposal for how we'd address this concern is to merge this now, and in the next major version to remove automatic pagination; moving that code into an add-on that can be used in conjunction with the baseline package. That add-on would be a shim that's only for backwards compatibility, but not encouraged.
Another concern is now the
cursorPaginationEnabledMethods
inmethods.ts
value is starting to store metadata about API responses, but outside of the holistic design we're hoping to arrive in #496 and #509.TODO
Add configuration for rate-limit retires (simple boolean) make webclient rate-limit retries configurable #451This can be done in a separate, follow-up PR, which will make it easier to review.Requirements (place an
x
in each[ ]
)