http: move rate-limiting out of client feature

this can now be used separately

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2023-01-25 11:43:01 +01:00
parent b62d76e80c
commit 10a3ab222b
6 changed files with 14 additions and 12 deletions

View File

@ -30,6 +30,8 @@ proxmox-lang = { workspace = true, optional = true }
[features]
default = []
rate-limiter = ["dep:hyper"]
rate-limited-stream = ["rate-limiter", "dep:tokio", "dep:hyper", "hyper?/client", "tokio?/time", "tokio?/net"]
client = [ "dep:futures", "http-helpers", "dep:hyper", "hyper?/full", "dep:openssl", "dep:tokio", "tokio?/io-util", "dep:tokio-openssl" ]
client-sync = [ "client-trait", "http-helpers", "dep:ureq" ]
client-trait = [ "dep:http" ]

View File

@ -18,7 +18,7 @@ use crate::proxy_config::ProxyConfig;
use crate::uri::build_authority;
use super::tls::MaybeTlsStream;
use super::{RateLimitedStream, ShareableRateLimit};
use crate::{RateLimitedStream, ShareableRateLimit};
type SharedRateLimit = Arc<dyn ShareableRateLimit>;

View File

@ -8,16 +8,6 @@
//!
//! Both clients implement [`HttpClient`](crate::HttpClient) if the feature `client-trait` is enabled.
#[cfg(feature = "client")]
mod rate_limiter;
#[cfg(feature = "client")]
pub use rate_limiter::{RateLimit, RateLimiter, RateLimiterVec, ShareableRateLimit};
#[cfg(feature = "client")]
mod rate_limited_stream;
#[cfg(feature = "client")]
pub use rate_limited_stream::RateLimitedStream;
#[cfg(feature = "client")]
mod connector;
#[cfg(feature = "client")]

View File

@ -23,3 +23,13 @@ pub mod client;
mod client_trait;
#[cfg(feature = "client-trait")]
pub use client_trait::HttpClient;
#[cfg(feature = "rate-limiter")]
mod rate_limiter;
#[cfg(feature = "rate-limiter")]
pub use rate_limiter::{RateLimit, RateLimiter, RateLimiterVec, ShareableRateLimit};
#[cfg(feature = "rate-limited-stream")]
mod rate_limited_stream;
#[cfg(feature = "rate-limited-stream")]
pub use rate_limited_stream::RateLimitedStream;

View File

@ -1,10 +1,10 @@
use std::future::Future;
use std::io::IoSlice;
use std::marker::Unpin;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use futures::Future;
use hyper::client::connect::{Connected, Connection};
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio::time::Sleep;