diff options
author | Yuchen Wu <[email protected]> | 2024-07-26 10:23:14 -0700 |
---|---|---|
committer | Yuchen Wu <[email protected]> | 2024-07-26 13:35:13 -0700 |
commit | 32303b9258fed5ce7d214515bddb2b7a0585fbe0 (patch) | |
tree | 5c51cf1f2f298c8bd212cf37a2d37b1ad73c3380 | |
parent | ff2582a64a5926c7ad0909f3c26b9da9ce578ba4 (diff) | |
download | pingora-32303b9258fed5ce7d214515bddb2b7a0585fbe0.tar.gz pingora-32303b9258fed5ce7d214515bddb2b7a0585fbe0.zip |
Address Rust 1.80 clippy warnings.
Also remove the doc_async_trait cfg since it is no longer viable.
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | pingora-cache/src/eviction/lru.rs | 1 | ||||
-rw-r--r-- | pingora-cache/src/lib.rs | 6 | ||||
-rw-r--r-- | pingora-core/Cargo.toml | 2 | ||||
-rw-r--r-- | pingora-core/src/apps/http_app.rs | 6 | ||||
-rw-r--r-- | pingora-core/src/apps/mod.rs | 6 | ||||
-rw-r--r-- | pingora-core/src/apps/prometheus_http_app.rs | 2 | ||||
-rw-r--r-- | pingora-core/src/lib.rs | 2 | ||||
-rw-r--r-- | pingora-core/src/protocols/http/server.rs | 2 | ||||
-rw-r--r-- | pingora-core/src/protocols/l4/ext.rs | 11 | ||||
-rw-r--r-- | pingora-core/src/services/background.rs | 2 | ||||
-rw-r--r-- | pingora-load-balancing/src/health_check.rs | 4 | ||||
-rw-r--r-- | pingora-proxy/Cargo.toml | 7 | ||||
-rw-r--r-- | pingora-proxy/src/lib.rs | 3 | ||||
-rw-r--r-- | pingora/Cargo.toml | 1 |
15 files changed, 29 insertions, 28 deletions
@@ -1 +1 @@ -b73e79a6e5ec1d56b300124ffd9839dcf288e2c9
\ No newline at end of file +c90e4ce2596840c60b5ff1737e2141447e5953e1 diff --git a/pingora-cache/src/eviction/lru.rs b/pingora-cache/src/eviction/lru.rs index 91bc8fc..fa09fab 100644 --- a/pingora-cache/src/eviction/lru.rs +++ b/pingora-cache/src/eviction/lru.rs @@ -32,6 +32,7 @@ use std::time::SystemTime; /// /// - Space optimized in-memory LRU (see [pingora_lru]). /// - Instead of a single giant LRU, this struct shards the assets into `N` independent LRUs. +/// /// This allows [EvictionManager::save()] not to lock the entire cache manager while performing /// serialization. pub struct Manager<const N: usize>(Lru<CompactCacheKey, N>); diff --git a/pingora-cache/src/lib.rs b/pingora-cache/src/lib.rs index 6ba057e..86cfbdf 100644 --- a/pingora-cache/src/lib.rs +++ b/pingora-cache/src/lib.rs @@ -344,10 +344,10 @@ impl HttpCache { /// - `storage`: the cache storage backend that implements [storage::Storage] /// - `eviction`: optionally the eviction manager, without it, nothing will be evicted from the storage /// - `predictor`: optionally a cache predictor. The cache predictor predicts whether something is likely - /// to be cacheable or not. This is useful because the proxy can apply different types of optimization to - /// cacheable and uncacheable requests. + /// to be cacheable or not. This is useful because the proxy can apply different types of optimization to + /// cacheable and uncacheable requests. /// - `cache_lock`: optionally a cache lock which handles concurrent lookups to the same asset. Without it - /// such lookups will all be allowed to fetch the asset independently. + /// such lookups will all be allowed to fetch the asset independently. pub fn enable( &mut self, storage: &'static (dyn storage::Storage + Sync), diff --git a/pingora-core/Cargo.toml b/pingora-core/Cargo.toml index c13823c..c5bce77 100644 --- a/pingora-core/Cargo.toml +++ b/pingora-core/Cargo.toml @@ -81,4 +81,4 @@ jemallocator = "0.5" default = ["openssl"] openssl = ["pingora-openssl"] boringssl = ["pingora-boringssl"] -patched_http1 = [] +patched_http1 = []
\ No newline at end of file diff --git a/pingora-core/src/apps/http_app.rs b/pingora-core/src/apps/http_app.rs index 6983e8e..91ca58a 100644 --- a/pingora-core/src/apps/http_app.rs +++ b/pingora-core/src/apps/http_app.rs @@ -28,7 +28,7 @@ use crate::protocols::Stream; use crate::server::ShutdownWatch; /// This trait defines how to map a request to a response -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] pub trait ServeHttp { /// Define the mapping from a request to a response. /// Note that the request header is already read, but the implementation needs to read the @@ -42,7 +42,7 @@ pub trait ServeHttp { } // TODO: remove this in favor of HttpServer? -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] impl<SV> HttpServerApp for SV where SV: ServeHttp + Send + Sync, @@ -128,7 +128,7 @@ impl<SV> HttpServer<SV> { } } -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] impl<SV> HttpServerApp for HttpServer<SV> where SV: ServeHttp + Send + Sync, diff --git a/pingora-core/src/apps/mod.rs b/pingora-core/src/apps/mod.rs index 758eb37..32fd82f 100644 --- a/pingora-core/src/apps/mod.rs +++ b/pingora-core/src/apps/mod.rs @@ -28,7 +28,7 @@ use crate::protocols::Digest; use crate::protocols::Stream; use crate::protocols::ALPN; -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] /// This trait defines the interface of a transport layer (TCP or TLS) application. pub trait ServerApp { /// Whenever a new connection is established, this function will be called with the established @@ -62,7 +62,7 @@ pub struct HttpServerOptions { } /// This trait defines the interface of an HTTP application. -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] pub trait HttpServerApp { /// Similar to the [`ServerApp`], this function is called whenever a new HTTP session is established. /// @@ -95,7 +95,7 @@ pub trait HttpServerApp { async fn http_cleanup(&self) {} } -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] impl<T> ServerApp for T where T: HttpServerApp + Send + Sync + 'static, diff --git a/pingora-core/src/apps/prometheus_http_app.rs b/pingora-core/src/apps/prometheus_http_app.rs index 38072bb..128ba6c 100644 --- a/pingora-core/src/apps/prometheus_http_app.rs +++ b/pingora-core/src/apps/prometheus_http_app.rs @@ -29,7 +29,7 @@ use crate::protocols::http::ServerSession; /// collected via the [Prometheus](https://docs.rs/prometheus/) crate; pub struct PrometheusHttpApp; -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] impl ServeHttp for PrometheusHttpApp { async fn response(&self, _http_session: &mut ServerSession) -> Response<Vec<u8>> { let encoder = TextEncoder::new(); diff --git a/pingora-core/src/lib.rs b/pingora-core/src/lib.rs index 3435fe5..4c3e29a 100644 --- a/pingora-core/src/lib.rs +++ b/pingora-core/src/lib.rs @@ -18,8 +18,6 @@ #![allow(clippy::match_wild_err_arm)] #![allow(clippy::missing_safety_doc)] #![allow(clippy::upper_case_acronyms)] -// enable nightly feature async trait so that the docs are cleaner -#![cfg_attr(doc_async_trait, feature(async_fn_in_trait))] //! # Pingora //! diff --git a/pingora-core/src/protocols/http/server.rs b/pingora-core/src/protocols/http/server.rs index 7e8d7e3..74aada6 100644 --- a/pingora-core/src/protocols/http/server.rs +++ b/pingora-core/src/protocols/http/server.rs @@ -53,7 +53,7 @@ impl Session { /// else with the session. /// - `Ok(true)`: successful /// - `Ok(false)`: client exit without sending any bytes. This is normal on reused connection. - /// In this case the user should give up this session. + /// In this case the user should give up this session. pub async fn read_request(&mut self) -> Result<bool> { match self { Self::H1(s) => { diff --git a/pingora-core/src/protocols/l4/ext.rs b/pingora-core/src/protocols/l4/ext.rs index 56af522..5123bdf 100644 --- a/pingora-core/src/protocols/l4/ext.rs +++ b/pingora-core/src/protocols/l4/ext.rs @@ -369,13 +369,10 @@ fn wrap_os_connect_error(e: std::io::Error, context: String) -> Box<Error> { Error::because(InternalError, context, e) } _ => match e.raw_os_error() { - Some(code) => match code { - libc::ENETUNREACH | libc::EHOSTUNREACH => { - Error::because(ConnectNoRoute, context, e) - } - _ => Error::because(ConnectError, context, e), - }, - None => Error::because(ConnectError, context, e), + Some(libc::ENETUNREACH | libc::EHOSTUNREACH) => { + Error::because(ConnectNoRoute, context, e) + } + _ => Error::because(ConnectError, context, e), }, } } diff --git a/pingora-core/src/services/background.rs b/pingora-core/src/services/background.rs index 4eec577..2b84532 100644 --- a/pingora-core/src/services/background.rs +++ b/pingora-core/src/services/background.rs @@ -26,7 +26,7 @@ use super::Service; use crate::server::{ListenFds, ShutdownWatch}; /// The background service interface -#[cfg_attr(not(doc_async_trait), async_trait)] +#[async_trait] pub trait BackgroundService { /// This function is called when the pingora server tries to start all the /// services. The background service can return at anytime or wait for the diff --git a/pingora-load-balancing/src/health_check.rs b/pingora-load-balancing/src/health_check.rs index ce4dc2a..ba5e6c0 100644 --- a/pingora-load-balancing/src/health_check.rs +++ b/pingora-load-balancing/src/health_check.rs @@ -133,9 +133,9 @@ pub struct HttpHealthCheck { /// Whether the underlying TCP/TLS connection can be reused across checks. /// /// * `false` will make sure that every health check goes through TCP (and TLS) handshakes. - /// Established connections sometimes hide the issue of firewalls and L4 LB. + /// Established connections sometimes hide the issue of firewalls and L4 LB. /// * `true` will try to reuse connections across checks, this is the more efficient and fast way - /// to perform health checks. + /// to perform health checks. pub reuse_connection: bool, /// The request header to send to the backend pub req: RequestHeader, diff --git a/pingora-proxy/Cargo.toml b/pingora-proxy/Cargo.toml index 65f7f67..0a52dff 100644 --- a/pingora-proxy/Cargo.toml +++ b/pingora-proxy/Cargo.toml @@ -55,3 +55,10 @@ serde_yaml = "0.8" default = ["openssl"] openssl = ["pingora-core/openssl", "pingora-cache/openssl"] boringssl = ["pingora-core/boringssl", "pingora-cache/boringssl"] + +# or locally cargo doc --config "build.rustdocflags='--cfg doc_async_trait'" +[package.metadata.docs.rs] +rustdoc-args = ["--cfg", "doc_async_trait"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_async_trait)'] }
\ No newline at end of file diff --git a/pingora-proxy/src/lib.rs b/pingora-proxy/src/lib.rs index a02b23f..eebf65d 100644 --- a/pingora-proxy/src/lib.rs +++ b/pingora-proxy/src/lib.rs @@ -35,9 +35,6 @@ //! //! See `examples/load_balancer.rs` for a detailed example. -// enable nightly feature async trait so that the docs are cleaner -#![cfg_attr(doc_async_trait, feature(async_fn_in_trait))] - use async_trait::async_trait; use bytes::Bytes; use futures::future::FutureExt; diff --git a/pingora/Cargo.toml b/pingora/Cargo.toml index 75baf1b..7f5e101 100644 --- a/pingora/Cargo.toml +++ b/pingora/Cargo.toml @@ -63,3 +63,4 @@ boringssl = [ proxy = ["pingora-proxy"] lb = ["pingora-load-balancing", "proxy"] cache = ["pingora-cache"] +time = [] |