mailgun / gubernator

High Performance Rate Limiting MicroService and Library
Apache License 2.0
964 stars 99 forks source link

Change global behavior #219

Closed thrawn01 closed 8 months ago

thrawn01 commented 9 months ago

Purpose

To change how GLOBAL behavior operates. Previously, the owner of the rate limit would broadcast the computed result of the rate limit to other peers, and the computed result from the owner is returned to clients who submit hits to a peer. However, after some great feed back on #218 and #216 It has become clear that we should instead allow the local peers to compute the result of the request based on the hits broadcast by the owning peer.

In the new behavior a peer will compute the result of the rate limit request and immediately return that computed result. This means that the non owning peer will compute the result with the current Remaining value it currently has in it's cache. To put it another way, the peer cache will no longer hold the computed result from the owner.

In order to facilitate this change, I've added many more tests around global functionality which should help ensure we don't break behavior going forward.

Implementation

This PR replaces #218 and #216 but keeps the commits from those PR's

Thank you to these wonderful people, for giving great feed back and working on this!

thrawn01 commented 8 months ago

@Baliedge rebased and ready to merge ❤️