nvo_servers
Not very opinionated servers
Build
| Branch | OS | Status |
|---|---|---|
| main | Linux | |
| main | macOS/FreeBSD |
🖥️ Platform Support
- Linux (epoll-based)
- macOS (kqueue-based)
- FreeBSD (kqueue-based)
Examples
For the best example, look into ./examples/async_linux_macos.rs.
This example starts a MongoDB in a container (Docker is required). It contains a POST handler that saves body into DB and a GET request that parses a path argument and loads data from the DB.
Cargo.toml
[]
= { = "https://github.com/pirkus/nvo_servers", = "v0.0.10" }
Async I/O HTTP Server
Multithreaded server that automatically scales to CPU core count.
use ;
use HashSet;
Chunked Response Example
use ;
// Note: Chunked responses are primarily useful when building custom HTTP handling.
// The ResponseBuilder provides utilities for creating properly formatted chunked responses.
let chunked_response = ok
.header
.chunked
.chunk
.chunk
.chunk
.build_http_string;
// This creates a properly formatted HTTP/1.1 chunked response:
// HTTP/1.1 200 OK
// Content-Type: text/plain
// Transfer-Encoding: chunked
//
// 5
// Hello
// 1
//
// 6
// World!
// 0
//
Blocking I/O HTTP Server
Also multithreaded with automatic CPU core scaling.
use ;
use HashSet;
Connection Pooling
The library includes built-in connection pooling:
use ConnectionPool;
use Duration;
// Create a pool with max 100 connections and 5-minute timeout
let pool = new;
// The pool is automatically used by the async servers
Performance Testing
To send requests for testing:
# Basic load test
# Test with keep-alive disabled
# Test chunked encoding
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.