mirror of
https://github.com/cloudflare/pingora.git
synced 2024-09-20 02:31:35 +02:00
Address Rust 1.80 clippy warnings.
Also remove the doc_async_trait cfg since it is no longer viable.
This commit is contained in:
parent
ff2582a64a
commit
32303b9258
15 changed files with 29 additions and 28 deletions
2
.bleep
2
.bleep
|
@ -1 +1 @@
|
|||
b73e79a6e5ec1d56b300124ffd9839dcf288e2c9
|
||||
c90e4ce2596840c60b5ff1737e2141447e5953e1
|
||||
|
|
|
@ -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>);
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -81,4 +81,4 @@ jemallocator = "0.5"
|
|||
default = ["openssl"]
|
||||
openssl = ["pingora-openssl"]
|
||||
boringssl = ["pingora-boringssl"]
|
||||
patched_http1 = []
|
||||
patched_http1 = []
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
//!
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)'] }
|
|
@ -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;
|
||||
|
|
|
@ -63,3 +63,4 @@ boringssl = [
|
|||
proxy = ["pingora-proxy"]
|
||||
lb = ["pingora-load-balancing", "proxy"]
|
||||
cache = ["pingora-cache"]
|
||||
time = []
|
||||
|
|
Loading…
Reference in a new issue