Skip to content

Commit

Permalink
Merge pull request #31 from alexrudy:merge-all
Browse files Browse the repository at this point in the history
Merge all sub-crates into a single crate
  • Loading branch information
alexrudy authored Apr 4, 2024
2 parents 1d36c6e + 3468967 commit 61ed09e
Show file tree
Hide file tree
Showing 79 changed files with 500 additions and 745 deletions.
491 changes: 194 additions & 297 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 3 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
[workspace]
members = [
"arnold",
"braid",
"bridge",
"hyperdrive",
"patron",
"pidfile",
"platter",
"roomservice",
]
members = ["hyperdriver"]
resolver = "2"

[workspace.dependencies]
arnold = { path = "./arnold" }
braid = { path = "./braid" }
bridge = { path = "./bridge" }
patron = { path = "./patron" }
pidfile = { path = "./pidfile" }

axum = "0.7"
bytes = "1"
Expand All @@ -29,6 +15,7 @@ http-body = { version = "1" }
http-body-util = { version = "0.1" }
humantime-serde = "1.1.1"
hyper = { version = "1", features = ["full"] }
libc = { version = "*" }
ouroboros = "0.18"
pem-rfc7468 = { version = "0.7", features = ["alloc"] }
pin-project = { version = "1" }
Expand All @@ -43,4 +30,5 @@ tokio = { version = "1" }
tokio-rustls = "0.26"
tower = { version = "0.4" }
tracing = { version = "^0.1" }
tracing-subscriber = { version = "^0.2" }
tracing-test = { version = "*" }
23 changes: 0 additions & 23 deletions arnold/Cargo.toml

This file was deleted.

32 changes: 0 additions & 32 deletions braid/Cargo.toml

This file was deleted.

12 changes: 0 additions & 12 deletions bridge/Cargo.toml

This file was deleted.

18 changes: 0 additions & 18 deletions hyperdrive/Cargo.toml

This file was deleted.

14 changes: 0 additions & 14 deletions hyperdrive/src/lib.rs

This file was deleted.

44 changes: 44 additions & 0 deletions hyperdriver/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[package]
name = "hyperdriver"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
axum = { workspace = true, optional = true }
bytes.workspace = true
camino = { workspace = true, features = ["serde1"] }
dashmap.workspace = true
futures-core.workspace = true
futures-util.workspace = true
http-body-util.workspace = true
http-body.workspace = true
http.workspace = true
humantime-serde.workspace = true
hyper = { workspace = true }
libc.workspace = true
ouroboros.workspace = true
pin-project.workspace = true
rustls-native-certs.workspace = true
rustls.workspace = true
serde = { workspace = true, features = ["derive"] }
socket2.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["full"] }
tokio-rustls.workspace = true
tower = { workspace = true, features = ["util", "make"] }
tracing.workspace = true

[dev-dependencies]
static-assertions.workspace = true
tracing-subscriber.workspace = true
tempfile.workspace = true

[features]
default = []
docs = []
incoming = []

[package.metadata.cargo-machete]
ignored = ["humantime-serde"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use http::Uri;
use http_body_util::BodyExt as _;
use patron::Client;
use hyperdriver::client::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use http::Uri;
use http_body_util::BodyExt as _;
use patron::{Client, HttpProtocol};
use hyperdriver::client::{Client, HttpProtocol};
use tokio::io::AsyncWriteExt;

#[tokio::main]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::arg;
use http::{HeaderName, HeaderValue, Uri};
use http_body_util::BodyExt as _;
use patron::Client;
use hyperdriver::client::Client;
use tokio::io::AsyncWriteExt as _;

#[tokio::main]
Expand Down Expand Up @@ -29,9 +29,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
};

let body = if let Some(body) = args.get_one::<String>("body") {
arnold::Body::from(body.to_owned())
hyperdriver::body::Body::from(body.to_owned())
} else {
arnold::Body::empty()
hyperdriver::body::Body::empty()
};

let mut req = http::Request::builder()
Expand Down
11 changes: 7 additions & 4 deletions platter/examples/h2.rs → hyperdriver/examples/server/h2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::net::{SocketAddr, SocketAddrV4};
use std::pin::pin;
use std::sync::Arc;

use bridge::rt::TokioExecutor;
use hyper::body::Incoming;
use hyper::server::conn::http2;
use hyperdriver::bridge::rt::TokioExecutor;

fn tls_config(domain: &str) -> rustls::ServerConfig {
let cert_data = std::fs::read(format!("minica/{domain}/cert.pem")).unwrap();
Expand Down Expand Up @@ -38,15 +38,18 @@ async fn main() {
let incoming = tokio::net::TcpListener::bind(addr).await.unwrap();
let addr = incoming.local_addr().unwrap();

let acceptor = braid::server::Acceptor::from(incoming).tls(Arc::new(tls_config("localhost")));
let acceptor = hyperdriver::stream::server::Acceptor::from(incoming)
.tls(Arc::new(tls_config("localhost")));

let server = platter::Server::new(
let server = hyperdriver::server::Server::new(
acceptor,
tower::service_fn(|_| async {
Ok::<_, hyper::Error>(tower::service_fn(|req: http::Request<Incoming>| async {
let body = req.into_body();
let data = body.collect().await?;
Ok::<_, hyper::Error>(hyper::Response::new(arnold::Body::from(data.to_bytes())))
Ok::<_, hyper::Error>(hyper::Response::new(hyperdriver::body::Body::from(
data.to_bytes(),
)))
}))
}),
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use rustls::ClientConfig;

use crate::{conn::http::HttpConnectionBuilder, default_tls_config, Client};
use crate::client::{conn::http::HttpConnectionBuilder, default_tls_config, Client};

#[derive(Debug)]
pub struct Builder {
tcp: crate::conn::TcpConnectionConfig,
tcp: crate::client::conn::TcpConnectionConfig,
tls: Option<ClientConfig>,
pool: Option<crate::pool::Config>,
conn: crate::conn::http::HttpConnectionBuilder,
pool: Option<crate::client::pool::Config>,
conn: crate::client::conn::http::HttpConnectionBuilder,
}

impl Default for Builder {
Expand All @@ -22,7 +22,7 @@ impl Default for Builder {
}

impl Builder {
pub fn tcp(&mut self) -> &mut crate::conn::TcpConnectionConfig {
pub fn tcp(&mut self) -> &mut crate::client::conn::TcpConnectionConfig {
&mut self.tcp
}

Expand All @@ -31,11 +31,11 @@ impl Builder {
self
}

pub fn pool(&mut self) -> &mut Option<crate::pool::Config> {
pub fn pool(&mut self) -> &mut Option<crate::client::pool::Config> {
&mut self.pool
}

pub fn conn(&mut self) -> &mut crate::conn::http::HttpConnectionBuilder {
pub fn conn(&mut self) -> &mut crate::client::conn::http::HttpConnectionBuilder {
&mut self.conn
}
}
Expand All @@ -45,9 +45,9 @@ impl Builder {
let tls = self.tls.unwrap_or_else(super::default_tls_config);

Client {
transport: crate::conn::TcpConnector::new(self.tcp, tls),
transport: crate::client::conn::TcpConnector::new(self.tcp, tls),
protocol: HttpConnectionBuilder::default(),
pool: self.pool.map(crate::pool::Pool::new),
pool: self.pool.map(crate::client::pool::Pool::new),
}
}
}
Loading

0 comments on commit 61ed09e

Please sign in to comment.