2 stable releases
1.0.1 | Aug 30, 2021 |
---|---|
1.0.0 | Oct 24, 2020 |
#1228 in Database interfaces
1.5MB
207 lines
Bouncer helps you to manage your requests to third-party services.
Setup
In order to use Bouncer, you need Redis as a backend. Then you can configure Redis URI:
#config/default.toml
server_url="redis://username:password@redis/"
Usage
Imagine you have a function that makes a request to a services.
fn dummy_function() {
let mut easy = Easy::new();
easy.url("http://httpbin.org/delay/3").unwrap();
easy.write_function(|data| {
stdout().write_all(data).unwrap();
Ok(data.len())
}).unwrap();
easy.perform().unwrap();
}
You can use bouncer to call that function many times in many place i.e. asynch jobs and let bouncer handle the request.
bouncer::run(KEY, RATE_LIMIT, WAIT_TIME, &dummy_function)
Dependencies
~12MB
~214K SLoC