Crates.io | radegast |
lib.rs | radegast |
version | 0.3.0 |
source | src |
created_at | 2023-09-21 14:01:19.221333 |
updated_at | 2024-01-18 11:08:36.679249 |
description | Fiber friendly http client for tarantool apps. |
homepage | |
repository | https://git.picodata.io/picodata/picodata/radegast |
max_upload_size | |
id | 979529 |
size | 20,845 |
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).
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.
We use tarantool-test. Run tests:
cargo build
tarantool-test -p ./target/debug/libtests.so