#service #requests #third-party #handle #manage #helps #redis

bouncer

Bouncer allows you handle your requests to third-party services with no worries, perhaps some worries

2 stable releases

1.0.1 Aug 30, 2021
1.0.0 Oct 24, 2020

#1228 in Database interfaces

MIT license

1.5MB
207 lines

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