radegast

Crates.ioradegast
lib.rsradegast
version0.3.0
sourcesrc
created_at2023-09-21 14:01:19.221333
updated_at2024-01-18 11:08:36.679249
descriptionFiber friendly http client for tarantool apps.
homepage
repositoryhttps://git.picodata.io/picodata/picodata/radegast
max_upload_size
id979529
size20,845
(picodata-account)

documentation

README

Radegast

An HTTP client for picodata apps. Non blocking, fiber friendly, driven by CBUS. Build over reqwest client.

This client has a similar API as reqwest crate (see docs for more).

Usage example

The main difference between this crate and reqwest is the HTTP client initialization.

First, initialize client using client builder:

    use radegast::ClientBuilder;
    use tarantool::cbus;
    use tarantool::fiber::Fiber;

    pub const CBUS_ENDPOINT: &str = "tests_endpoint";

    // initialize cbus first
    pub fn init_cbus() {
        let mut fiber = Fiber::new("cbus_endpoint_f", &mut |_: Box<()>| {
            let cbus_endpoint = cbus::Endpoint::new(CBUS_ENDPOINT).unwrap();
            cbus_endpoint.cbus_loop();
            0
        });
        fiber.start(());
    }

    fn main() {
        init_cbus();
        let client = radegast::ClientBuilder::new().build(CBUS_ENDPOINT).unwrap();
    }

If you want, you can manually define a tokio runtime (instead of default) for run HTTP requests and reqwest client underline instance (see ClientBuilder methods). Now you have the opportunity to make an HTTP request:

    let response = client.get("https://google.ru").send().unwrap();
    println!("{response:?}");

To familiarize with request APIs you can see the reqwest docs.

Tests

We use tarantool-test. Run tests:

    cargo build
    tarantool-test -p ./target/debug/libtests.so
Commit count: 0

cargo fmt