Skip to content

Commit

Permalink
Merge pull request #299 from plabayo/feat/client-layers-split-crates
Browse files Browse the repository at this point in the history
split crates into core and regular
  • Loading branch information
GlenDC authored Sep 1, 2024
2 parents b434c4b + 84afa3c commit 1afe5fb
Show file tree
Hide file tree
Showing 364 changed files with 2,079 additions and 2,473 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
cargo clippy --workspace --all-targets --features=full
- name: rustfmt
run: |
cargo fmt --workspace -- --check
cargo fmt --all --check
check:
runs-on: ubuntu-latest
Expand All @@ -50,7 +50,7 @@ jobs:
cargo clippy --workspace --all-targets --features=full
- name: rustfmt
run: |
cargo fmt --workspace -- --check
cargo fmt --all --check
check-all-features:
runs-on: ubuntu-latest
Expand All @@ -69,7 +69,7 @@ jobs:
cargo clippy --workspace --all-targets --all-features
- name: rustfmt
run: |
cargo fmt --workspace -- --check
cargo fmt --all --check
test-msrv:
needs: [check, check-msrv, check-all-features]
Expand Down
27 changes: 23 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = [".", "fuzz", "rama-cli", "rama-macros"]
members = [".", "fuzz", "rama-cli", "rama-core", "rama-macros"]

[workspace.package]
version = "0.2.0-alpha.2"
Expand Down Expand Up @@ -118,7 +118,7 @@ rust-version = { workspace = true }

[features]
default = ["compression"]
full = ["telemetry", "compression", "boring"]
full = ["telemetry", "compression", "boring", "cli"]
telemetry = [
"dep:opentelemetry",
"dep:opentelemetry_sdk",
Expand All @@ -127,6 +127,7 @@ telemetry = [
compression = ["dep:async-compression"]
rustls-ring = ["tokio-rustls/ring", "rustls/ring"]
boring = ["dep:boring", "dep:tokio-boring"]
cli = []

[build-dependencies]
rustversion = { workspace = true }
Expand All @@ -150,7 +151,6 @@ futures-lite = { workspace = true }
h2 = { workspace = true }
headers = { workspace = true }
hex = { workspace = true }
hickory-resolver = { workspace = true }
http = { workspace = true }
http-body = { workspace = true }
http-body-util = { workspace = true }
Expand All @@ -170,8 +170,7 @@ parking_lot = { workspace = true }
paste = { workspace = true }
percent-encoding = { workspace = true }
pin-project-lite = { workspace = true }
quickcheck = { workspace = true }
rama-macros = { version = "0.2.0-alpha.2", path = "rama-macros" }
rama-core = { version = "0.2.0-alpha.2", path = "rama-core" }
rcgen = { workspace = true }
regex = { workspace = true }
rustls = { workspace = true }
Expand All @@ -184,7 +183,6 @@ serde_json = { workspace = true }
sync_wrapper = { workspace = true }
tokio = { workspace = true, features = ["macros", "fs", "io-std"] }
tokio-boring = { workspace = true, optional = true }
tokio-graceful = { workspace = true }
tokio-rustls = { workspace = true }
tokio-util = { workspace = true }
tracing = { workspace = true }
Expand Down Expand Up @@ -215,7 +213,6 @@ opt-level = 3
[profile.dev]
debug = false
opt-level = 1
incremental = false

[package.metadata.docs.rs]
all-features = true
Expand All @@ -224,3 +221,15 @@ rustdoc-args = ["--cfg", "docsrs"]
[[bench]]
name = "ua_parse"
harness = false

[[example]]
name = "tls_boring_termination"
required-features = ["boring"]

[[example]]
name = "http_telemetry"
required-features = ["telemetry"]

[[example]]
name = "http_high_level_client"
required-features = ["compression"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ This framework comes with 🔋 batteries included, giving you the full freedome
|[transports](https://ramaproxy.org/docs/rama/net/stream/index.html) |[tcp](https://ramaproxy.org/docs/rama/tcp/index.html) ⸱ 🏗️ udp <sup>(2)</sup> ⸱ ✅ [middleware](https://ramaproxy.org/docs/rama/net/stream/layer/index.html) |
|[http](https://ramaproxy.org/docs/rama/http/index.html) |[auto](https://ramaproxy.org/docs/rama/http/server/service/struct.HttpServer.html#method.auto) ⸱ ✅ [http/1.1](https://ramaproxy.org/docs/rama/http/server/service/struct.HttpServer.html#method.http1) ⸱ ✅ [h2](https://ramaproxy.org/docs/rama/http/server/service/struct.HttpServer.html#method.h2) ⸱ 🏗️ h3 <sup>(2)</sup> ⸱ ✅ [middleware](https://ramaproxy.org/docs/rama/http/layer/index.html) |
| ✅ web server |[fs](https://ramaproxy.org/docs/rama/http/service/fs/index.html) ⸱ ✅ [redirect](https://ramaproxy.org/docs/rama/http/service/redirect/struct.Redirect.html) ⸱ ✅ [dyn router](https://ramaproxy.org/docs/rama/http/service/web/struct.WebService.html) ⸱ ✅ [static router](https://ramaproxy.org/docs/rama/http/service/web/macro.match_service.html) ⸱ ✅ [handler extractors](https://ramaproxy.org/docs/rama/http/service/web/extract/index.html) ⸱ ✅ [k8s healthcheck](https://ramaproxy.org/docs/rama/http/service/web/k8s/index.html) |
| ✅ http [client](https://ramaproxy.org/docs/rama/http/client/index.html) |[client](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) ⸱ ✅ [high level API](https://ramaproxy.org/docs/rama/http/client/trait.HttpClientExt.html) ⸱ ✅ [Proxy Connect](https://ramaproxy.org/docs/rama/proxy/http/client/layer/struct.HttpProxyConnectorService.html) ⸱ ❌ [Chromium Http](https://github.com/plabayo/rama/issues/189) <sup>(3)</sup> |
| ✅ http [client](https://ramaproxy.org/docs/rama/http/client/index.html) |[client](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) ⸱ ✅ [high level API](https://ramaproxy.org/docs/rama/http/client/trait.HttpClientExt.html) ⸱ ✅ [Proxy Connect](https://ramaproxy.org/docs/rama/proxy/http/client/layer/struct.HttpProxyConnector.html) ⸱ ❌ [Chromium Http](https://github.com/plabayo/rama/issues/189) <sup>(3)</sup> |
|[tls](https://ramaproxy.org/docs/rama/tls/index.html) |[Rustls](https://ramaproxy.org/docs/rama/tls/rustls/index.html) ⸱ ✅ [BoringSSL](https://ramaproxy.org/docs/rama/tls/boring/index.html) ⸱ ❌ NSS <sup>(3)</sup> |
|[dns](https://ramaproxy.org/docs/rama/dns/index.html) |[DNS Resolver](https://ramaproxy.org/docs/rama/dns/struct.Dns.html) |
|[proxy protocols](https://ramaproxy.org/docs/rama/proxy/index.html) |[PROXY protocol](https://ramaproxy.org/docs/rama/proxy/pp/index.html) ⸱ ✅ [http proxy](https://github.com/plabayo/rama/blob/main/examples/http_connect_proxy.rs) ⸱ ✅ [https proxy](https://github.com/plabayo/rama/blob/main/examples/https_connect_proxy.rs) ⸱ 🏗️ SOCKS5 <sup>(1)</sup> ⸱ 🏗️ SOCKS5H <sup>(1)</sup> |
Expand Down
2 changes: 1 addition & 1 deletion docs/book/src/preface.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ This framework comes with 🔋 batteries included, giving you the full freedome
|[transports](https://ramaproxy.org/docs/rama/net/stream/index.html) |[tcp](https://ramaproxy.org/docs/rama/tcp/index.html) ⸱ 🏗️ udp <sup>(2)</sup> ⸱ ✅ [middleware](https://ramaproxy.org/docs/rama/net/stream/layer/index.html) |
|[http](https://ramaproxy.org/docs/rama/http/index.html) |[auto](https://ramaproxy.org/docs/rama/http/server/service/struct.HttpServer.html#method.auto) ⸱ ✅ [http/1.1](https://ramaproxy.org/docs/rama/http/server/service/struct.HttpServer.html#method.http1) ⸱ ✅ [h2](https://ramaproxy.org/docs/rama/http/server/service/struct.HttpServer.html#method.h2) ⸱ 🏗️ h3 <sup>(2)</sup> ⸱ ✅ [middleware](https://ramaproxy.org/docs/rama/http/layer/index.html) |
| ✅ web server |[fs](https://ramaproxy.org/docs/rama/http/service/fs/index.html) ⸱ ✅ [redirect](https://ramaproxy.org/docs/rama/http/service/redirect/struct.Redirect.html) ⸱ ✅ [dyn router](https://ramaproxy.org/docs/rama/http/service/web/struct.WebService.html) ⸱ ✅ [static router](https://ramaproxy.org/docs/rama/http/service/web/macro.match_service.html) ⸱ ✅ [handler extractors](https://ramaproxy.org/docs/rama/http/service/web/extract/index.html) ⸱ ✅ [k8s healthcheck](https://ramaproxy.org/docs/rama/http/service/web/k8s/index.html) |
| ✅ http [client](https://ramaproxy.org/docs/rama/http/client/index.html) |[client](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) ⸱ ✅ [high level API](https://ramaproxy.org/docs/rama/http/client/trait.HttpClientExt.html) ⸱ ✅ [Proxy Connect](https://ramaproxy.org/docs/rama/proxy/http/client/layer/struct.HttpProxyConnectorService.html) ⸱ ❌ [Chromium Http](https://github.com/plabayo/rama/issues/189) <sup>(3)</sup> |
| ✅ http [client](https://ramaproxy.org/docs/rama/http/client/index.html) |[client](https://ramaproxy.org/docs/rama/http/client/struct.HttpClient.html) ⸱ ✅ [high level API](https://ramaproxy.org/docs/rama/http/client/trait.HttpClientExt.html) ⸱ ✅ [Proxy Connect](https://ramaproxy.org/docs/rama/proxy/http/client/layer/struct.HttpProxyConnector.html) ⸱ ❌ [Chromium Http](https://github.com/plabayo/rama/issues/189) <sup>(3)</sup> |
|[tls](https://ramaproxy.org/docs/rama/tls/index.html) |[Rustls](https://ramaproxy.org/docs/rama/tls/rustls/index.html) ⸱ ✅ [BoringSSL](https://ramaproxy.org/docs/rama/tls/boring/index.html) ⸱ ❌ NSS <sup>(3)</sup> |
|[dns](https://ramaproxy.org/docs/rama/dns/index.html) |[DNS Resolver](https://ramaproxy.org/docs/rama/dns/struct.Dns.html) |
|[proxy protocols](https://ramaproxy.org/docs/rama/proxy/index.html) |[PROXY protocol](https://ramaproxy.org/docs/rama/proxy/pp/index.html) ⸱ ✅ [http proxy](https://github.com/plabayo/rama/blob/main/examples/http_connect_proxy.rs) ⸱ ✅ [https proxy](https://github.com/plabayo/rama/blob/main/examples/https_connect_proxy.rs) ⸱ 🏗️ SOCKS5 <sup>(1)</sup> ⸱ 🏗️ SOCKS5H <sup>(1)</sup> |
Expand Down
7 changes: 5 additions & 2 deletions examples/http_conn_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
//! connection index and count of requests within that connection.

use rama::{
context::AsRef,
http::{response::Html, server::HttpServer, Request},
layer::MapStateLayer,
rt::Executor,
service::{context::AsRef, layer::MapStateLayer, service_fn, Context, Layer},
service::service_fn,
tcp::server::TcpListener,
Context, Layer,
};
use std::{
convert::Infallible,
Expand Down Expand Up @@ -114,7 +117,7 @@ where

#[tokio::main]
async fn main() {
let graceful = rama::utils::graceful::Shutdown::default();
let graceful = rama::graceful::Shutdown::default();

graceful.spawn_task_fn(|guard| async move {
let exec = Executor::graceful(guard.clone());
Expand Down
10 changes: 7 additions & 3 deletions examples/http_connect_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
//! ```

use rama::{
context::Extensions,
http::{
client::HttpClient,
layer::{
Expand All @@ -71,13 +72,16 @@ use rama::{
service::web::{extract::Path, match_service},
Body, IntoResponse, Request, RequestContext, Response, StatusCode,
},
net::{address::Domain, stream::layer::http::BodyLimitLayer, user::Basic},
layer::HijackLayer,
net::{address::Domain, user::Basic},
rt::Executor,
service::{context::Extensions, layer::HijackLayer, service_fn, Context, Layer, Service},
service::service_fn,
stream::layer::http::BodyLimitLayer,
tcp::{server::TcpListener, utils::is_connection_error},
utils::username::{
UsernameLabelParser, UsernameLabelState, UsernameLabels, UsernameOpaqueLabelParser,
},
Context, Layer, Service,
};
use serde::Deserialize;
use serde_json::json;
Expand All @@ -96,7 +100,7 @@ async fn main() {
)
.init();

let graceful = rama::utils::graceful::Shutdown::default();
let graceful = rama::graceful::Shutdown::default();

#[derive(Deserialize)]
/// API parameters for the lucky number endpoint
Expand Down
4 changes: 2 additions & 2 deletions examples/http_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use rama::http::matcher::HttpMatcher;
use rama::http::response::Html;
use rama::http::service::web::{extract::Form, WebService};
use rama::http::{IntoResponse, Response};
use rama::service::Layer;
use rama::Layer;
use rama::{http::server::HttpServer, rt::Executor};
use serde::{Deserialize, Serialize};
use std::time::Duration;
Expand All @@ -65,7 +65,7 @@ async fn main() {
)
.init();

let graceful = rama::utils::graceful::Shutdown::default();
let graceful = rama::graceful::Shutdown::default();

graceful.spawn_task_fn(|guard| async move {
let exec = Executor::graceful(guard.clone());
Expand Down
2 changes: 1 addition & 1 deletion examples/http_high_level_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use rama::{
Body, BodyExtractExt, IntoResponse, Request, Response, StatusCode,
},
rt::Executor,
service::{Context, Layer, Service},
utils::{backoff::ExponentialBackoff, rng::HasherRng},
Context, Layer, Service,
};

// Everything else we need is provided by the standard library, community crates or tokio.
Expand Down
2 changes: 1 addition & 1 deletion examples/http_key_value_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use rama::{
IntoResponse, Method, StatusCode,
},
rt::Executor,
service::Layer,
Layer,
};
use serde::Deserialize;
use serde_json::json;
Expand Down
11 changes: 7 additions & 4 deletions examples/http_mitm_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ use rama::{
server::HttpServer,
Body, IntoResponse, Request, RequestContext, Response, StatusCode,
},
net::{stream::layer::http::BodyLimitLayer, user::Basic},
layer::ConsumeErrLayer,
net::user::Basic,
rt::Executor,
service::{layer::ConsumeErrLayer, service_fn, Layer, Service},
service::service_fn,
stream::layer::http::BodyLimitLayer,
tcp::server::TcpListener,
tls::{
dep::rcgen::KeyPair,
Expand All @@ -63,6 +65,7 @@ use rama::{
server::TlsAcceptorLayer,
},
},
Layer, Service,
};
use std::{convert::Infallible, sync::Arc, time::Duration};
use tracing::level_filters::LevelFilter;
Expand All @@ -73,7 +76,7 @@ struct State {
mitm_tls_config: Arc<ServerConfig>,
}

type Context = rama::service::Context<State>;
type Context = rama::Context<State>;

#[tokio::main]
async fn main() -> Result<(), BoxError> {
Expand All @@ -93,7 +96,7 @@ async fn main() -> Result<(), BoxError> {
);
let state = State { mitm_tls_config };

let graceful = rama::utils::graceful::Shutdown::default();
let graceful = rama::graceful::Shutdown::default();

graceful.spawn_task_fn(|guard| async move {
let tcp_service = TcpListener::build_with_state(state)
Expand Down
17 changes: 8 additions & 9 deletions examples/http_rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,20 @@
use std::{convert::Infallible, sync::Arc, time::Duration};

use rama::{
combinators::Either,
error::BoxError,
http::{
matcher::HttpMatcher, response::Json, server::HttpServer, HeaderName, HeaderValue,
IntoResponse, Request, Response, StatusCode,
},
net::stream::matcher::SocketMatcher,
rt::Executor,
service::{
layer::{
limit::policy::{ConcurrentPolicy, LimitReached},
LimitLayer, MapResultLayer, TraceErrLayer,
},
service_fn, Layer,
layer::{
limit::policy::{ConcurrentPolicy, LimitReached},
Layer, LimitLayer, MapResultLayer, TraceErrLayer,
},
utils::{backoff::ExponentialBackoff, combinators::Either},
rt::Executor,
service::service_fn,
stream::matcher::SocketMatcher,
utils::backoff::ExponentialBackoff,
};
use serde_json::json;

Expand Down
3 changes: 2 additions & 1 deletion examples/http_service_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

use rama::{
http::{server::HttpServer, service::fs::ServeDir},
layer::TraceErrLayer,
rt::Executor,
service::{layer::TraceErrLayer, Layer},
tcp::server::TcpListener,
Layer,
};

#[tokio::main]
Expand Down
13 changes: 6 additions & 7 deletions examples/http_service_hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ use rama::{
server::HttpServer,
IntoResponse, Request,
},
net::stream::{
layer::{MapResponseLayer, TimeoutLayer, TraceErrLayer},
rt::Executor,
service::service_fn,
stream::{
layer::{BytesRWTrackerHandle, IncomingBytesTrackerLayer},
SocketInfo,
},
rt::Executor,
service::{
layer::{MapResponseLayer, TimeoutLayer, TraceErrLayer},
service_fn, Context, Layer,
},
tcp::server::TcpListener,
utils::latency::LatencyUnit,
Context, Layer,
};
use std::{sync::Arc, time::Duration};
use tracing::level_filters::LevelFilter;
Expand All @@ -61,7 +60,7 @@ async fn main() {
)
.init();

let graceful = rama::utils::graceful::Shutdown::default();
let graceful = rama::graceful::Shutdown::default();

let sensitive_headers: Arc<[_]> = vec![header::AUTHORIZATION, header::COOKIE].into();

Expand Down
2 changes: 1 addition & 1 deletion examples/http_service_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rama::{
Request,
},
rt::Executor,
service::Layer,
Layer,
};

use serde_json::json;
Expand Down
Loading

0 comments on commit 1afe5fb

Please sign in to comment.