preparing nightly-build
This commit is contained in:
parent
92638ccd2a
commit
f41a2213f9
13 changed files with 109 additions and 110 deletions
5
rpxy-lib/src/forwarder/cache/cache_error.rs
vendored
5
rpxy-lib/src/forwarder/cache/cache_error.rs
vendored
|
|
@ -1,6 +1,6 @@
|
|||
use thiserror::Error;
|
||||
|
||||
pub type CacheResult<T> = std::result::Result<T, CacheError>;
|
||||
pub(crate) type CacheResult<T> = std::result::Result<T, CacheError>;
|
||||
|
||||
/// Describes things that can go wrong in the Rpxy
|
||||
#[derive(Debug, Error)]
|
||||
|
|
@ -9,9 +9,6 @@ pub enum CacheError {
|
|||
#[error("Invalid null request and/or response")]
|
||||
NullRequestOrResponse,
|
||||
|
||||
#[error("Failed to write byte buffer")]
|
||||
FailedToWriteByteBufferForCache,
|
||||
|
||||
#[error("Failed to acquire mutex lock for cache")]
|
||||
FailedToAcquiredMutexLockForCache,
|
||||
|
||||
|
|
|
|||
20
rpxy-lib/src/forwarder/cache/cache_main.rs
vendored
20
rpxy-lib/src/forwarder/cache/cache_main.rs
vendored
|
|
@ -30,7 +30,7 @@ use tokio::{
|
|||
/* ---------------------------------------------- */
|
||||
#[derive(Clone, Debug)]
|
||||
/// Cache main manager
|
||||
pub struct RpxyCache {
|
||||
pub(crate) struct RpxyCache {
|
||||
/// Inner lru cache manager storing http message caching policy
|
||||
inner: LruCacheManager,
|
||||
/// Managing cache file objects through RwLock's lock mechanism for file lock
|
||||
|
|
@ -47,7 +47,7 @@ pub struct RpxyCache {
|
|||
|
||||
impl RpxyCache {
|
||||
/// Generate cache storage
|
||||
pub async fn new(globals: &Globals) -> Option<Self> {
|
||||
pub(crate) async fn new(globals: &Globals) -> Option<Self> {
|
||||
if !globals.proxy_config.cache_enabled {
|
||||
return None;
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ impl RpxyCache {
|
|||
}
|
||||
|
||||
/// Count cache entries
|
||||
pub async fn count(&self) -> (usize, usize, usize) {
|
||||
pub(crate) async fn count(&self) -> (usize, usize, usize) {
|
||||
let total = self.inner.count();
|
||||
let file = self.file_store.count().await;
|
||||
let on_memory = total - file;
|
||||
|
|
@ -88,7 +88,7 @@ impl RpxyCache {
|
|||
}
|
||||
|
||||
/// Put response into the cache
|
||||
pub async fn put(
|
||||
pub(crate) async fn put(
|
||||
&self,
|
||||
uri: &hyper::Uri,
|
||||
mut body: Incoming,
|
||||
|
|
@ -186,7 +186,7 @@ impl RpxyCache {
|
|||
}
|
||||
|
||||
/// Get cached response
|
||||
pub async fn get<R>(&self, req: &Request<R>) -> Option<Response<ResponseBody>> {
|
||||
pub(crate) async fn get<R>(&self, req: &Request<R>) -> Option<Response<ResponseBody>> {
|
||||
debug!(
|
||||
"Current cache status: (total, on-memory, file) = {:?}",
|
||||
self.count().await
|
||||
|
|
@ -394,7 +394,7 @@ impl FileStoreInner {
|
|||
|
||||
#[derive(Clone, Debug)]
|
||||
/// Cache target in hybrid manner of on-memory and file system
|
||||
pub enum CacheFileOrOnMemory {
|
||||
pub(crate) enum CacheFileOrOnMemory {
|
||||
/// Pointer to the temporary cache file
|
||||
File(PathBuf),
|
||||
/// Cached body itself
|
||||
|
|
@ -418,11 +418,11 @@ impl CacheFileOrOnMemory {
|
|||
/// Cache object definition
|
||||
struct CacheObject {
|
||||
/// Cache policy to determine if the stored cache can be used as a response to a new incoming request
|
||||
pub policy: CachePolicy,
|
||||
policy: CachePolicy,
|
||||
/// Cache target: on-memory object or temporary file
|
||||
pub target: CacheFileOrOnMemory,
|
||||
target: CacheFileOrOnMemory,
|
||||
/// SHA256 hash of target to strongly bind the cache metadata (this object) and file target
|
||||
pub hash: Bytes,
|
||||
hash: Bytes,
|
||||
}
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
|
|
@ -490,7 +490,7 @@ impl LruCacheManager {
|
|||
|
||||
/* ---------------------------------------------- */
|
||||
/// Generate cache policy if the response is cacheable
|
||||
pub fn get_policy_if_cacheable<B1, B2>(
|
||||
pub(crate) fn get_policy_if_cacheable<B1, B2>(
|
||||
req: Option<&Request<B1>>,
|
||||
res: Option<&Response<B2>>,
|
||||
) -> CacheResult<Option<CachePolicy>>
|
||||
|
|
|
|||
2
rpxy-lib/src/forwarder/cache/mod.rs
vendored
2
rpxy-lib/src/forwarder/cache/mod.rs
vendored
|
|
@ -2,4 +2,4 @@ mod cache_error;
|
|||
mod cache_main;
|
||||
|
||||
pub use cache_error::CacheError;
|
||||
pub use cache_main::{get_policy_if_cacheable, CacheFileOrOnMemory, RpxyCache};
|
||||
pub(crate) use cache_main::{get_policy_if_cacheable, RpxyCache};
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ where
|
|||
<B as Body>::Error: Into<Box<(dyn std::error::Error + Send + Sync + 'static)>>,
|
||||
{
|
||||
/// Build inner client with http
|
||||
pub fn try_new(_globals: &Arc<Globals>) -> RpxyResult<Self> {
|
||||
pub async fn try_new(_globals: &Arc<Globals>) -> RpxyResult<Self> {
|
||||
warn!(
|
||||
"
|
||||
--------------------------------------------------------------------------------------------------
|
||||
|
|
@ -134,6 +134,7 @@ Please enable native-tls-backend or rustls-backend feature to enable TLS support
|
|||
let mut http = HttpConnector::new();
|
||||
http.set_reuse_address(true);
|
||||
let inner = Client::builder(executor).build::<_, B>(http);
|
||||
let inner_h2 = inner.clone();
|
||||
|
||||
Ok(Self {
|
||||
inner,
|
||||
|
|
@ -191,7 +192,7 @@ where
|
|||
|
||||
#[cfg(feature = "rustls-backend")]
|
||||
/// Build forwarder with hyper-rustls (rustls)
|
||||
impl<B1> Forwarder<hyper_tls::HttpsConnector<HttpConnector>, B1>
|
||||
impl<B1> Forwarder<HttpConnector, B1>
|
||||
where
|
||||
B1: Body + Send + Unpin + 'static,
|
||||
<B1 as Body>::Data: Send,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue