Kvarn uses Tokio as the asynchronous runtime. It’s the same used in deno. Every extension is asynchronous. This enables parallel execution to requests.
If you need to send a request to your database or read a file, use async APIs. See the Tokio docs for more info.
This uses Rust’s built-in async-await syntax. If you need any library for IO (networking, file system, database connections), there probably exist an async version at crates.io.
You can of course also use synchronous APIs, but that blocks other requests, and
is therefore strongly discouraged. Consider using
spawn_blocking
instead.
Crate
To support these efforts, a
kvarn_async
is available. It also
allows you to read from an async source to Bytes
,
without an intermediate Vec
.
You can view it’s documentation online.