Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lrascao/raterl
An erlang ETS based rate limiter inspired by Jobs
https://github.com/lrascao/raterl
erlang rate-limiter
Last synced: about 2 months ago
JSON representation
An erlang ETS based rate limiter inspired by Jobs
- Host: GitHub
- URL: https://github.com/lrascao/raterl
- Owner: lrascao
- License: apache-2.0
- Created: 2017-02-09T18:25:11.000Z (almost 8 years ago)
- Default Branch: develop
- Last Pushed: 2021-07-13T12:54:45.000Z (over 3 years ago)
- Last Synced: 2024-09-30T01:48:10.191Z (3 months ago)
- Topics: erlang, rate-limiter
- Language: Erlang
- Size: 37.1 KB
- Stars: 16
- Watchers: 5
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://github.com/lrascao/raterl/workflows/build/badge.svg)](https://github.com/lrascao/raterl)
# raterl
Erlang flow control application heavily inspired in `jobs` and `ratx`,
ETS based bypasses the `jobs_server` single process bottleneck while
providing `rate` and `counter` flow control.## Supports
## TODO
* Queues
* Modifiers## Examples
### Rate flow control
A typical use case is restricting the number of logins per second
on a system, you'd start by the configuration:```erlang
[{raterl, [
{queues, [
{login_requests, [
{regulator, [
{name, max_login_rate},
{type, rate},
{limit, 100} %% ensures that we get no more than x logins per second
]}
]}
]}
]
}].
```Then on the code you ask permission from `raterl` before accepting a login:
```erlang
case raterl:run(login_requests, {rate, max_login_rate}, fun () -> Ret end) of
limit_reached ->
{error, throttled};
Ret -> Ret
end;
```Build
-----$ rebar3 compile