https://kotlinlang.org logo
#coroutines
Title
# coroutines
n

Nikky

02/07/2019, 2:25 AM
i am dealing with a super slowed paged api, limited to a pagesize of 1000 currently i just reqest it concurrently and stop once the result size drops under the requested page size what would be a clean solution to request 10 pages at a time and mark which one results in less results than the requested pagesize ? i was thinking of having a fixedThreadpool process from a channel and the first one that finds the end will somehow trigger that no more jobs are being created.. but not sure how to do this and ofc its not actually guaranted that there is no shifting of data between the requests.. there might be entries added or removed 🤮
g

gildor

02/07/2019, 2:57 AM
If API doesn’t provide safe pagination solution you cannot solve it on your side
not sure what you mean about
what would be a clean solution to request 10 pages at a time and mark which one results in less results than the requested pagesize ?
n

Nikky

02/07/2019, 3:15 AM
i guess what i mean by that is how to process multiple pages at the same time but also limit concurrency to
n
i guess its a worker pool ?
g

gildor

02/07/2019, 5:01 AM
Yes, worker pool
but also you can just start 10 coroutines.
Something like that https://pl.kotl.in/r1Dk0EKVV
3 Views