softwaremill / ox

Safe direct-style concurrency and resiliency for Scala on the JVM
https://ox.softwaremill.com
Apache License 2.0
391 stars 28 forks source link

Rate control primitives? #120

Open windymelt opened 7 months ago

windymelt commented 7 months ago

Hi! At first, thank you for great async library! I tried examples and played exercises using documentation. It was full of fun!

My suggestion is providing rate control primitives (e.g. simple rate limit, smart (leaky bucket / token bucket) algorithm).

Sometimes I want rate control in production concurrent programming (e.g. batch processing along HTTP API).

Of course, we can implement simple control using par() and Source.tick(). But in production use, I think out-of-the-box rate control primitives is preferred.

adamw commented 7 months ago

Thanks! Definitely, rate control is something that will be great to include, and very much in-line with the scope of the project, in the "resiliency" part.

adamw commented 4 weeks ago

Just as Ox has repeat and retry, the goal here is to implement a rate limiter. Similarly to other resilience operation, this should come with a configuration object.

Rate limiting itself should be possible in a stateful way, e.g. given a RateLimiter.apply(=> T): T method, which will block if the rate limit is reached. But we're open to any other suggestions.

As to the rate limiting configuration options, the algorithm mentioned in the original description should be available. Moreover, resilience4j might provide more inspiration.

adamw commented 4 weeks ago

/bounty $500

algora-pbc[bot] commented 4 weeks ago

💎 $500 bounty • SoftwareMill

Steps to solve:

  1. Start working: Comment /attempt #120 with your implementation plan
  2. Submit work: Create a pull request including /claim #120 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to softwaremill/ox!

Add a bounty • Share on socials

Attempt Started (GMT+0) Solution
🟢 @paulpdaniels Oct 16, 2024, 3:20:03 PM WIP
🟢 @rathi-dev Oct 17, 2024, 8:43:44 AM WIP
🟢 @vishalpatil1899 Oct 21, 2024, 1:22:21 AM WIP
🟢 @pablf #235
paulpdaniels commented 3 weeks ago

/attempt #120

Algora profile Completed bounties Tech Active attempts Options
@paulpdaniels 3 bounties from 1 project
Scala, JavaScript,
TypeScript & more
Cancel attempt
rathi-dev commented 3 weeks ago

/attempt #120

algora-pbc[bot] commented 3 weeks ago

💡 @pablf submitted a pull request that claims the bounty. You can visit your bounty board to reward.

vishalpatil1899 commented 3 weeks ago

/attempt #120

adamw commented 3 weeks ago

As we are getting first PRs for the bounties, I've published our "How to prepare a good PR" guide. I should have probably done this right away, sorry! :)