Skip to content

Commit

Permalink
fix:lint
Browse files Browse the repository at this point in the history
  • Loading branch information
NxPKG committed Nov 25, 2024
1 parent 01599f8 commit e89eb3c
Show file tree
Hide file tree
Showing 61 changed files with 97 additions and 95 deletions.
2 changes: 1 addition & 1 deletion bongonet-cache/src/cache_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
use super::*;

use bongonet_error::{Error, ErrorType};
use http::header::HeaderName;
use http::HeaderValue;
use indexmap::IndexMap;
use once_cell::sync::Lazy;
use bongonet_error::{Error, ErrorType};
use regex::bytes::Regex;
use std::num::IntErrorKind;
use std::slice;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/eviction/simple_lru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use super::EvictionManager;
use crate::key::CompactCacheKey;

use async_trait::async_trait;
use bongonet_error::{BError, ErrorType::*, OrErr, Result};
use lru::LruCache;
use parking_lot::RwLock;
use bongonet_error::{BError, ErrorType::*, OrErr, Result};
use serde::de::SeqAccess;
use serde::{Deserialize, Serialize};
use std::collections::hash_map::DefaultHasher;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use super::*;
use crate::cache_control::{CacheControl, Cacheable, InterpretCacheControl};
use crate::RespCacheable::*;

use bongonet_http::RequestHeader;
use http::{header, HeaderValue};
use httpdate::HttpDate;
use log::warn;
use bongonet_http::RequestHeader;

/// Decide if the request can be cacheable
pub fn request_cacheable(req_header: &ReqHeader) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions bongonet-cache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#![allow(clippy::new_without_default)]

use bongonet_error::Result;
use bongonet_http::ResponseHeader;
use http::{method::Method, request::Parts as ReqHeader, response::Parts as RespHeader};
use key::{CacheHashKey, HashBinary};
use lock::WritePermit;
use bongonet_error::Result;
use bongonet_http::ResponseHeader;
use rustracing::tag::Tag;
use std::time::{Duration, Instant, SystemTime};
use trace::CacheTraceCTX;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/max_file_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use crate::storage::HandleMiss;
use crate::MissHandler;
use async_trait::async_trait;
use bytes::Bytes;
use bongonet_error::{Error, ErrorType};
use bytes::Bytes;

/// [MaxFileSizeMissHandler] wraps a MissHandler to enforce a maximum asset size that should be
/// written to the MissHandler.
Expand Down
2 changes: 1 addition & 1 deletion bongonet-cache/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use crate::storage::{streaming_write::U64WriteId, HandleHit, HandleMiss};
use crate::trace::SpanHandle;

use async_trait::async_trait;
use bongonet_error::*;
use bytes::Bytes;
use parking_lot::RwLock;
use bongonet_error::*;
use std::any::Any;
use std::collections::HashMap;
use std::sync::atomic::{AtomicU64, Ordering};
Expand Down
4 changes: 2 additions & 2 deletions bongonet-cache/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

//! Metadata for caching
pub use http::Extensions;
use bongonet_error::{Error, ErrorType::*, OrErr, Result};
use bongonet_http::{HMap, ResponseHeader};
pub use http::Extensions;
use serde::{Deserialize, Serialize};
use std::time::{Duration, SystemTime};

Expand Down Expand Up @@ -561,9 +561,9 @@ impl CacheMetaDefaults {
}
}

use bongonet_header_serde::HeaderSerde;
use log::warn;
use once_cell::sync::{Lazy, OnceCell};
use bongonet_header_serde::HeaderSerde;
use std::fs::File;
use std::io::Read;

Expand Down
8 changes: 4 additions & 4 deletions bongonet-cache/src/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
//! Cache Put module
use crate::*;
use bytes::Bytes;
use http::header;
use bongonet_core::protocols::http::{
v1::common::header_value_content_length, HttpTask, ServerSession,
};
use bytes::Bytes;
use http::header;

/// The interface to define cache put behavior
pub trait CachePut {
Expand Down Expand Up @@ -344,12 +344,12 @@ mod test {

mod parse_response {
use super::*;
use bytes::BytesMut;
use httparse::Status;
use bongonet_error::{
Error,
ErrorType::{self, *},
};
use bytes::BytesMut;
use httparse::Status;

pub const INCOMPLETE_BODY: ErrorType = ErrorType::new("IncompleteHttpBody");

Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/apps/http_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
//! A simple HTTP application trait that maps a request to a response
use async_trait::async_trait;
use bongonet_http::ResponseHeader;
use http::Response;
use log::{debug, error, trace};
use bongonet_http::ResponseHeader;
use std::sync::Arc;

use crate::apps::HttpServerApp;
Expand Down
6 changes: 3 additions & 3 deletions bongonet-core/src/connectors/http/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use crate::protocols::http::v2::client::{drive_connection, Http2Session};
use crate::protocols::{Digest, Stream, UniqueIDType};
use crate::upstreams::peer::{Peer, ALPN};

use bongonet_error::{Error, ErrorType::*, OrErr, Result};
use bongonet_pool::{ConnectionMeta, ConnectionPool, PoolNode};
use bytes::Bytes;
use h2::client::SendRequest;
use log::debug;
use parking_lot::{Mutex, RwLock};
use bongonet_error::{Error, ErrorType::*, OrErr, Result};
use bongonet_pool::{ConnectionMeta, ConnectionPool, PoolNode};
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
Expand Down Expand Up @@ -393,8 +393,8 @@ async fn handshake(
max_streams: usize,
h2_ping_interval: Option<Duration>,
) -> Result<ConnectionRef> {
use h2::client::Builder;
use bongonet_runtime::current_handle;
use h2::client::Builder;

// Safe guard: new_http_session() assumes there should be at least one free stream
if max_streams == 0 {
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/connectors/l4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
// limitations under the License.

use async_trait::async_trait;
use log::debug;
use bongonet_error::{Context, Error, ErrorType::*, OrErr, Result};
use log::debug;
use rand::seq::SliceRandom;
use std::net::SocketAddr as InetSocketAddr;
#[cfg(unix)]
Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/connectors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ use crate::protocols::Stream;
use crate::server::configuration::ServerConf;
use crate::upstreams::peer::{Peer, ALPN};

use bongonet_error::{Error, ErrorType::*, OrErr, Result};
use bongonet_pool::{ConnectionMeta, ConnectionPool};
pub use l4::Connect as L4Connect;
use l4::{connect as l4_connect, BindTo};
use log::{debug, error, warn};
use offload::OffloadRuntime;
use parking_lot::RwLock;
use bongonet_error::{Error, ErrorType::*, OrErr, Result};
use bongonet_pool::{ConnectionMeta, ConnectionPool};
use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/connectors/tls/boringssl_openssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use log::debug;
use bongonet_error::{Error, ErrorType::*, OrErr, Result};
use log::debug;
use std::sync::{Arc, Once};

use crate::connectors::tls::replace_leftmost_underscore;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/connectors/tls/rustls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use std::sync::Arc;

use log::debug;
use bongonet_error::{
Error,
ErrorType::{ConnectTimedout, InvalidCert},
Expand All @@ -25,6 +24,7 @@ use bongonet_rustls::{
version, CertificateDer, ClientConfig as RusTlsClientConfig, PrivateKeyDer, RootCertStore,
TlsConnector as RusTlsConnector,
};
use log::debug;

use crate::protocols::tls::{client::handshake, TlsStream};
use crate::{connectors::ConnectorOptions, listeners::ALPN, protocols::IO, upstreams::peer::Peer};
Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/listeners/l4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use log::warn;
use bongonet_error::{
ErrorType::{AcceptError, BindError},
OrErr, Result,
};
use log::warn;
use std::fs::Permissions;
use std::io::ErrorKind;
use std::net::{SocketAddr, ToSocketAddrs};
Expand Down Expand Up @@ -93,8 +93,8 @@ pub struct TcpSocketOptions {
mod uds {
use super::{OrErr, Result};
use crate::protocols::l4::listener::Listener;
use log::{debug, error};
use bongonet_error::ErrorType::BindError;
use log::{debug, error};
use std::fs::{self, Permissions};
use std::io::ErrorKind;
use std::os::unix::fs::PermissionsExt;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/listeners/tls/boringssl_openssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use log::debug;
use bongonet_error::{ErrorType, OrErr, Result};
use log::debug;
use std::ops::{Deref, DerefMut};

pub use crate::protocols::tls::ALPN;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/listeners/tls/rustls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use std::sync::Arc;

use crate::listeners::TlsAcceptCallbacks;
use crate::protocols::tls::{server::handshake, server::handshake_with_callback, TlsStream};
use log::debug;
use bongonet_error::ErrorType::InternalError;
use bongonet_error::{Error, OrErr, Result};
use bongonet_rustls::load_certs_and_key_files;
use bongonet_rustls::ServerConfig;
use bongonet_rustls::{version, TlsAcceptor as RusTlsAcceptor};
use log::debug;

use crate::protocols::{ALPN, IO};

Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/modules/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ pub mod compression;
pub mod grpc_web;

use async_trait::async_trait;
use bongonet_error::Result;
use bongonet_http::{RequestHeader, ResponseHeader};
use bytes::Bytes;
use http::HeaderMap;
use once_cell::sync::OnceCell;
use bongonet_error::Result;
use bongonet_http::{RequestHeader, ResponseHeader};
use std::any::Any;
use std::any::TypeId;
use std::collections::HashMap;
Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/protocols/http/bridge/grpc_web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use bongonet_error::{ErrorType::ReadError, OrErr, Result};
use bongonet_http::{RequestHeader, ResponseHeader};
use bytes::{BufMut, Bytes, BytesMut};
use http::{
header::{CONTENT_LENGTH, CONTENT_TYPE, TRANSFER_ENCODING},
HeaderMap,
};
use bongonet_error::{ErrorType::ReadError, OrErr, Result};
use bongonet_http::{RequestHeader, ResponseHeader};

/// Used for bridging gRPC to gRPC-web and vice-versa.
/// See gRPC-web [spec](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md) and
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/protocols/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use bytes::Bytes;
use bongonet_error::Result;
use bongonet_http::{RequestHeader, ResponseHeader};
use bytes::Bytes;
use std::time::Duration;

use super::v1::client::HttpSession as Http1Session;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/protocols/http/compression/brotli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use super::Encode;
use super::COMPRESSION_ERROR;

use bongonet_error::{OrErr, Result};
use brotli::{CompressorWriter, DecompressorWriter};
use bytes::Bytes;
use bongonet_error::{OrErr, Result};
use std::io::Write;
use std::time::{Duration, Instant};

Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/protocols/http/compression/gzip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

use super::{Encode, COMPRESSION_ERROR};

use bongonet_error::{OrErr, Result};
use bytes::Bytes;
use flate2::write::{GzDecoder, GzEncoder};
use bongonet_error::{OrErr, Result};
use std::io::Write;
use std::time::{Duration, Instant};

Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/protocols/http/compression/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use super::HttpTask;

use bytes::Bytes;
use log::warn;
use bongonet_error::{ErrorType, Result};
use bongonet_http::{RequestHeader, ResponseHeader};
use bytes::Bytes;
use log::warn;
use std::time::Duration;

use strum::EnumCount;
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/protocols/http/compression/zstd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
// limitations under the License.

use super::{Encode, COMPRESSION_ERROR};
use bongonet_error::{OrErr, Result};
use bytes::Bytes;
use parking_lot::Mutex;
use bongonet_error::{OrErr, Result};
use std::io::Write;
use std::time::{Duration, Instant};
use zstd::stream::write::Encoder;
Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/protocols/http/conditional_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

//! Conditional filter (not modified) utilities
use http::{header::*, StatusCode};
use httpdate::{parse_http_date, HttpDate};
use bongonet_error::{ErrorType::InvalidHTTPHeader, OrErr, Result};
use bongonet_http::{RequestHeader, ResponseHeader};
use http::{header::*, StatusCode};
use httpdate::{parse_http_date, HttpDate};

/// Evaluates conditional headers according to the [RFC](https://datatracker.ietf.org/doc/html/rfc9111#name-handling-a-received-validat).
///
Expand Down
2 changes: 1 addition & 1 deletion bongonet-core/src/protocols/http/error_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

//! Error response generating utilities.
use bongonet_http::ResponseHeader;
use http::header;
use once_cell::sync::Lazy;
use bongonet_http::ResponseHeader;

use super::SERVER_NAME;

Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/protocols/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ use super::v1::server::HttpSession as SessionV1;
use super::v2::server::HttpSession as SessionV2;
use super::HttpTask;
use crate::protocols::{Digest, SocketAddr, Stream};
use bongonet_error::Result;
use bongonet_http::{RequestHeader, ResponseHeader};
use bytes::Bytes;
use http::HeaderValue;
use http::{header::AsHeaderName, HeaderMap};
use log::error;
use bongonet_error::Result;
use bongonet_http::{RequestHeader, ResponseHeader};
use std::time::Duration;

/// HTTP server session object for both HTTP/1.x and HTTP/2
Expand Down
4 changes: 2 additions & 2 deletions bongonet-core/src/protocols/http/v1/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use bytes::{Buf, BufMut, Bytes, BytesMut};
use log::{debug, trace, warn};
use bongonet_error::{
Error,
ErrorType::{self, *},
OrErr, Result,
};
use bytes::{Buf, BufMut, Bytes, BytesMut};
use log::{debug, trace, warn};
use std::fmt::Debug;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};

Expand Down
Loading

0 comments on commit e89eb3c

Please sign in to comment.