-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
Feature | V2 Paginator #152
Feature | V2 Paginator #152
Conversation
|
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.
Looking really good so far
Also if you want to try it against Saloon's test API here are two endpoints: per-page/page pagination: https://tests.saloon.dev/api/superheroes/per-page |
I'll fix the failing tests when I move 'resolving' parts out of I still have a lot of stuff to figure out. I think each of them should have an 'attached' |
@Sammyjo20 Technically speaking, 'paged' APIs should really always have 1 as the first page. |
Regarding serialising the I believe the only blocker, technically speaking, are middlewares as they can be Closures, that aren't really serialisable, AFAIK.
Same thing with the Maybe we could ask how much it'd be used, as well. Context: |
Yeah I actually agree on this one. We firstly have the issue as you mentioned with middleware and while I don't mind telling people "if you want to serialize the paginator, you have to switch to invokable class middleware" I don't actually know how many people would really use it. The only time I'd use it, would be if I was rate limited by the API - I would want to queue a job with the backoff time and then run the process again. That being said, this would actually solve a really annoying issue we have at work where an API only gets so far and then stops at exactly the same point because it gets rate limited. Did you figure out a way to "resume" the iteration process from where it was left off? I wonder if we set the page in the "rewind" method to be the unserialized last page, so it starts at page 10 for example. What we also could do is when we know we are on the last page, we reset the "starting point" back to zero so if someone starts iterating over it again, the rewind doesn't start at page 10 again. 💡 I kind of think it'll be worth it, especially when all they have to do is migrate middleware to be invokable classes which are cleaner typically. If we can implement it later on in v2 hopefully without any breaking changes then happy days, but I think what you have come up with will be great for now. |
Yeah - I've solved the iteration/paging continuation. If we want to continue in a separate process, we'd need to be able to serialise- and unserialise it to retain the same state.
Currently, the serialisation bits are actually a separate interface. But let me have a think next week, and maybe I can solve it with non-Closure middlewares. |
Co-authored-by: Juse Less <me@juseless.dev>
Co-authored-by: Juse Less <me@juseless.dev>
I tested a bit, and it looks like what I originally had is actually correct. See my recording of a quick testScreenShot.2023-02-15.at.03.03.14.mp4So to summarise - for the * @param iterable<\GuzzleHttp\Promise\PromiseInterface|\Saloon\Contracts\Request>|callable(\Saloon\Contracts\Connector): iterable<\GuzzleHttp\Promise\PromiseInterface|\Saloon\Contracts\Request> $requests I guess it makes sense to specify its keys, as well. Kinda redundant, but sometimes PHPStan wants them when giving iterables to methods or classes using templates. * @param iterable<array-key, \GuzzleHttp\Promise\PromiseInterface|\Saloon\Contracts\Request>|callable(\Saloon\Contracts\Connector): iterable<array-key, \GuzzleHttp\Promise\PromiseInterface|\Saloon\Contracts\Request> $requests |
Co-authored-by: Sam Carré <29132017+Sammyjo20@users.noreply.github.com>
Co-authored-by: Sam Carré <29132017+Sammyjo20@users.noreply.github.com>
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.
Self review
Co-authored-by: Juse Less <me@juseless.dev>
Co-authored-by: Juse Less <me@juseless.dev>
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.
Self review
We're finally good to go! Woohooo! Thanks @juse-less for the help with this <3 |
No description provided.