mirror of
https://github.com/binwiederhier/ntfy.git
synced 2026-11-10 14:44:04 +08:00
Allow(key, rule, n), Refund, Tokens and Usage on a service that keeps a token bucket and a daily count per key and kind, sharded by key, with the rule passed in on every call. The server's visitor keeps its identity and the resolved limits and asks the service; rate.Limiter, util.RateLimiter and util.FixedLimiter are gone from it (subscriptions stay a per-node gauge). util.RateLimiter, NewBytesLimiter and BurnTokens had no users left and are removed. Behavior changes: refunds work for every kind (a revert on the bandwidth limiter hands the bytes back), a tier change applies on the next request without handing back full buckets, a changed tier limit applies without a tier ID change, and the daily email limit is a real daily cap on top of the bucket. Step 2 of plans/261025-shared-rate-limits.md.