Crates.io | monoio-transports |
lib.rs | monoio-transports |
version | |
source | src |
created_at | 2024-01-11 18:40:27.798183 |
updated_at | 2024-10-28 04:27:39.777197 |
description | Monoio Transporter. |
homepage | |
repository | |
max_upload_size | |
id | 1096557 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
monoio-transports
is a high-performance, modular networking library built on top of the monoio
asynchronous runtime. It provides a set of connectors and utilities for efficient network
communications, optimized for use with io_uring.
The Connector
trait is the foundation of this crate's modular architecture. It defines a common interface for establishing network connections:
pub trait Connector<K> {
type Connection;
type Error;
fn connect(&self, key: K) -> impl Future<Output = Result<Self::Connection, Self::Error>>;
}
This trait allows for the creation of various connector types that can be easily composed and stacked to create complex connection setups.
The TransportConnMetadata
trait provides a way to retrieve additional information about
a connection, such as ALPN (Application-Layer Protocol Negotiation) details:
pub trait TransportConnMetadata {
type Metadata;
fn get_conn_metadata(&self) -> Self::Metadata;
}
TcpConnector
: Establishes TCP connectionsUnixConnector
: Establishes Unix Domain Socket connectionsUnifiedL4Connector
: A unified connector supporting both TCP and Unix Domain SocketsTlsConnector
adds TLS encryption to an underlying L4 connector, supporting both
native-tls and rustls backends.
HttpConnector
is a universal connector supporting both HTTP/1.1 and HTTP/2 protocols.
It can be used with various underlying connectors (TCP, Unix, TLS) and provides built-in
connection pooling for efficient resource usage and high performance.
The crate provides a generic, flexible connection pooling implementation that can be used with any type of connection:
ConnectionPool
: A generic pool that can manage and reuse any type of connection.PooledConnector
: A wrapper that adds pooling capabilities to any connector.This generic pooling system is currently utilized in:
HttpConnector
: Leverages connection pooling for both HTTP/1.1 and HTTP/2.hyper
feature is enabled): Utilize the pooling system for
efficient connection reuse compatible with the Hyper ecosystem.The flexibility of this pooling implementation allows developers to easily add connection reuse capabilities to their custom connectors or any other connection types. This results in high-performance clients that efficiently manage connections, significantly improving throughput and reducing latency in high-load scenarios across various protocols and connection types.
Connectors can be easily stacked to create powerful, flexible connection setups. For example:
use monoio_transports::{
connectors::{TcpConnector, TlsConnector},
HttpConnector,
};
// Simple TCP conenctor
let tcp_connector = TcpConnector::default();
// TLS conencttor with custom ALPN protocols set
let tls_connector = TlsConnector::new_with_tls_default(tcp_connector, Some(vec!["http/1.1"]));
// Https conector with HTTP_2 and HTTP_11 support.
let https_connector: HttpConnector<TlsConnector<TcpConnector>, _, _> = HttpConnector::default();
This example creates a connector stack that uses TCP for the base connection, adds TLS encryption, and then provides HTTP protocol handling on top with built-in connection pooling.
native-tls
: Enables the native-tls backend for TLS connectionshyper
: Enables integration with the Hyper HTTP library, including Hyper-compatible
connectors with efficient connection poolingBy leveraging monoio's efficient asynchronous runtime, io_uring, and advanced connection
pooling, monoio-transports
provides a powerful and flexible toolkit for building
high-performance network applications and HTTP clients.