Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mz2/mpratelimiter
A synchronous rate limiter for Swift: makes the current thread wait (as opposed to dispatching in the future after throttling rate limit has passed).
https://github.com/mz2/mpratelimiter
Last synced: 25 days ago
JSON representation
A synchronous rate limiter for Swift: makes the current thread wait (as opposed to dispatching in the future after throttling rate limit has passed).
- Host: GitHub
- URL: https://github.com/mz2/mpratelimiter
- Owner: mz2
- License: apache-2.0
- Created: 2016-04-24T02:10:50.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-04T17:18:33.000Z (over 7 years ago)
- Last Synced: 2024-10-19T23:23:50.545Z (28 days ago)
- Language: Swift
- Size: 37.1 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MPRateLimiter ![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)
A synchronous rate limiter for Swift.- The current thread waits for the closure's rate limited execution.
- Public interface is thread safe.
- Allows for rethrowing errors thrown by the rate limited executed closure.If you don't want this behaviour where waiting is done synchronously, and instead need rate limiting of the sort where rate limited execution may be dispatched asynchronously in another call stack, you may want to try something like [DORateLimit](https://github.com/danydev/DORateLimit) instead.
## Usage examples
```
let limiter = RateLimiter()// Executes at the maximum rate of 0.1s since the previously executed closure with matching key "foo"
limiter.execute(key:"foo", rateLimit:0.1) {
print("bar")
}
```