Crates.io | bouncer |
lib.rs | bouncer |
version | 1.0.1 |
source | src |
created_at | 2020-10-24 21:49:46.103952 |
updated_at | 2021-08-30 00:22:00.758584 |
description | Bouncer allows you handle your requests to third-party services with no worries, perhaps some worries. |
homepage | https://github.com/thelastinuit/bouncer |
repository | https://github.com/thelastinuit/bouncer.git |
max_upload_size | |
id | 305143 |
size | 1,514,850 |
Bouncer helps you to manage your requests to third-party services.
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/"
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)