Skip to content

Bouncer helps you to manage your requests to third-party services.

License

Notifications You must be signed in to change notification settings

The-Last-Inuit/bouncer

Repository files navigation

Rupertou

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:https://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:https://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)