aboutsummaryrefslogtreecommitdiffhomepage
path: root/pingora-cache
diff options
context:
space:
mode:
authorMatthew Gumport <[email protected]>2024-03-05 17:04:13 -0800
committerEdward Wang <[email protected]>2024-03-15 14:37:56 -0700
commitae8ea771b1a738b379b4061c7d7e20ca0e22a542 (patch)
tree0cb24c97cc31ff4a2f5b4dba329416f5f9221676 /pingora-cache
parent81e6adea4d38ae00387538fb48dd8a6aab1ad21f (diff)
downloadpingora-ae8ea771b1a738b379b4061c7d7e20ca0e22a542.tar.gz
pingora-ae8ea771b1a738b379b4061c7d7e20ca0e22a542.zip
compile and test cleanly with nightly
The vast majority of these are redundant imports.
Diffstat (limited to 'pingora-cache')
-rw-r--r--pingora-cache/src/cache_control.rs4
-rw-r--r--pingora-cache/src/eviction/lru.rs1
-rw-r--r--pingora-cache/src/filters.rs5
-rw-r--r--pingora-cache/src/memory.rs4
-rw-r--r--pingora-cache/src/put.rs10
5 files changed, 12 insertions, 12 deletions
diff --git a/pingora-cache/src/cache_control.rs b/pingora-cache/src/cache_control.rs
index 6686c3e..a8a893f 100644
--- a/pingora-cache/src/cache_control.rs
+++ b/pingora-cache/src/cache_control.rs
@@ -20,8 +20,7 @@ use http::header::HeaderName;
use http::HeaderValue;
use indexmap::IndexMap;
use once_cell::sync::Lazy;
-use pingora_error::{Error, ErrorType, Result};
-use pingora_http::ResponseHeader;
+use pingora_error::{Error, ErrorType};
use regex::bytes::Regex;
use std::num::IntErrorKind;
use std::slice;
@@ -434,7 +433,6 @@ pub trait InterpretCacheControl {
mod tests {
use super::*;
use http::header::CACHE_CONTROL;
- use http::HeaderValue;
use http::{request, response};
fn build_response(cc_key: HeaderName, cc_value: &str) -> response::Parts {
diff --git a/pingora-cache/src/eviction/lru.rs b/pingora-cache/src/eviction/lru.rs
index 35ceb77..9c00a94 100644
--- a/pingora-cache/src/eviction/lru.rs
+++ b/pingora-cache/src/eviction/lru.rs
@@ -233,7 +233,6 @@ impl<const N: usize> EvictionManager for Manager<N> {
mod test {
use super::*;
use crate::CacheKey;
- use EvictionManager;
// we use shard (N) = 1 for eviction consistency in all tests
diff --git a/pingora-cache/src/filters.rs b/pingora-cache/src/filters.rs
index 4255673..b84bbf7 100644
--- a/pingora-cache/src/filters.rs
+++ b/pingora-cache/src/filters.rs
@@ -16,12 +16,12 @@
use super::*;
use crate::cache_control::{CacheControl, Cacheable, InterpretCacheControl};
-use crate::{RespCacheable, RespCacheable::*};
+use crate::RespCacheable::*;
use http::{header, HeaderValue};
use httpdate::HttpDate;
use log::warn;
-use pingora_http::{RequestHeader, ResponseHeader};
+use pingora_http::RequestHeader;
/// Decide if the request can be cacheable
pub fn request_cacheable(req_header: &ReqHeader) -> bool {
@@ -206,6 +206,7 @@ pub mod upstream {
#[cfg(test)]
mod tests {
use super::*;
+ use crate::RespCacheable::Cacheable;
use http::header::{HeaderName, CACHE_CONTROL, EXPIRES, SET_COOKIE};
use http::StatusCode;
use httpdate::fmt_http_date;
diff --git a/pingora-cache/src/memory.rs b/pingora-cache/src/memory.rs
index 525bf23..6d0a519 100644
--- a/pingora-cache/src/memory.rs
+++ b/pingora-cache/src/memory.rs
@@ -19,8 +19,8 @@
//TODO: Mark this module #[test] only
use super::*;
-use crate::key::{CacheHashKey, CompactCacheKey};
-use crate::storage::{HandleHit, HandleMiss, Storage};
+use crate::key::CompactCacheKey;
+use crate::storage::{HandleHit, HandleMiss};
use crate::trace::SpanHandle;
use async_trait::async_trait;
diff --git a/pingora-cache/src/put.rs b/pingora-cache/src/put.rs
index c50cc2b..be0d510 100644
--- a/pingora-cache/src/put.rs
+++ b/pingora-cache/src/put.rs
@@ -264,14 +264,12 @@ mod test {
mod parse_response {
use super::*;
- use bytes::{Bytes, BytesMut};
+ use bytes::BytesMut;
use httparse::Status;
use pingora_error::{
Error,
ErrorType::{self, *},
- Result,
};
- use pingora_http::ResponseHeader;
pub const INVALID_CHUNK: ErrorType = ErrorType::new("InvalidChunk");
pub const INCOMPLETE_BODY: ErrorType = ErrorType::new("IncompleteHttpBody");
@@ -280,7 +278,7 @@ mod parse_response {
const INIT_HEADER_BUF_SIZE: usize = 4096;
const CHUNK_DELIMITER_SIZE: usize = 2; // \r\n
- #[derive(Debug, Clone, Copy)]
+ #[derive(Debug, Clone, Copy, PartialEq)]
enum ParseState {
Init,
PartialHeader,
@@ -561,6 +559,10 @@ mod parse_response {
let output = parser.inject_data(input);
// header is not complete
assert!(output.is_err());
+ match parser.state {
+ ParseState::Invalid(httparse::Error::Version) => {}
+ _ => panic!("should have failed to parse"),
+ }
}
#[test]