You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Look into tower as a replacement for deadpool + channels #36
While working on #33 I looked into existing libraries for network handling.
I even asked around on Twitter.
Turns out there is a neat little library called tower that was recommended by @shanesveller.
It handles many things that we currently do manually or not at all:
This module defines a load-balanced pool of services that adds new services when load is high.
The pool uses poll_ready as a signal indicating whether additional services should be spawned
to handle the current level of load. Specifically, every time poll_ready on the inner service
returns Ready, [Pool] consider that a 0, and every time it returns Pending, [Pool]
considers it a 1. [Pool] then maintains an exponential moving
average over those
samples, which gives an estimate of how often the underlying service has been ready when it was
needed "recently" (see [Builder::urgency]). If the service is loaded (see
[Builder::loaded_above]), a new service is created and added to the underlying [Balance].
If the service is underutilized (see [Builder::underutilized_below]) and there are two or
more services, then the latest added service is removed. In either case, the load estimate is
reset to its initial value (see [Builder::initial] to prevent services from being rapidly
added or removed.
(Sorry for quoting the entire thing, but I think it's quite rad.
AFAICT with that we can have some pool that optimizes network throughput.
If anyone has comments on the pros and cons of tower I'd love to hear them.
Perhaps somebody even wants to investigate and create a PR for it?
Also drafted a rate limit parser yesterday: https://github.com/mre/rate-limit
There's a lot missing still (please create issues over there!), but I think we can use it to parse actual rate limits from the requests once we get there. That's much better than guessing the limits. Of course, we'd still have to have a sane default for sites that don't send rate limit headers.
Activity
mre commentedon Apr 6, 2021
Here is an example for how to wrap reqwest with tower: seanmonstar/reqwest#491
mre commentedon Mar 25, 2022
There's also https://github.com/antifuchs/governor. We could consider writing a middleware for tower around that.
mre commentedon Mar 25, 2022
Also drafted a rate limit parser yesterday: https://github.com/mre/rate-limit
There's a lot missing still (please create issues over there!), but I think we can use it to parse actual rate limits from the requests once we get there. That's much better than guessing the limits. Of course, we'd still have to have a sane default for sites that don't send rate limit headers.
mre commentedon Mar 28, 2022
Also see https://github.com/james7132/Hourai/blob/4a4b343f237f726ae1d2e2943e0bed58406f2cf6/logger/hourai-feeds/src/reddit/rate_limiter.rs
mre commentedon Jan 6, 2025
lychee's architecture has diverged significantly from tower's model. It's unlikely at this point that we will adopt it for lychee.