mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-30 00:47:13 +00:00
chore: adjudicate the last 18 bare dead_code allows in the library crates
Finishes backlog#1823 step 10 outside `rustfs/src` and `protocols`: config, s3select-query, common, madmin, heal, ecstore, signer and notify. Stripped first, then clippy asked which the compiler actually missed — 8 of the 18 were inert. Seven items are deleted, each checked by grep as well as by clippy: - `common/last_minute.rs`'s private `TimedAction` (with its impl) and `SizeCategory` (with its `Display` impl). The file's public surface — `AccElem`, `LastMinuteLatency` — stays; ecstore consumes it. - `s3select-query`'s three `with_*` builders. `DefaultLogicalOptimizer::with_optimizer_rules` looks used, but the call in the same file is `SessionStateBuilder::with_optimizer_rules` from DataFusion; the local methods have no callers. - `heal/manager.rs`'s `contains_key`. Its six apparent references are all `HashMap::contains_key`. Three keep their code: - `heal/storage.rs`'s `Test` variant is constructed by the `#[cfg(test)] test()` helper, which the lib target cannot see, so it takes a reasoned allow. - `signer`'s `STREAMING_PAYLOAD_HDR` and `try_build_chunk_string_to_sign` gain the `_` prefix instead. That file already marks deliberately-unheld code that way — `_STREAMING_TRAILER_HDR`, `_PAYLOAD_CHUNK_SIZE`, and `_try_build_chunk_signature`, which is the only caller of that function. Following the existing convention removes the allow without an attribute. `protocols` keeps its four; that crate needs `--features swift,sftp` to compile fully and is verified differently. The four `#![allow(dead_code)]` in `e2e_test` are module-root blankets in test-support files, which belong to steps 1-5 rather than step 10. Refs backlog#1823
This commit is contained in:
@@ -13,82 +13,6 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct TimedAction {
|
|
||||||
count: u64,
|
|
||||||
acc_time: u64,
|
|
||||||
min_time: Option<u64>,
|
|
||||||
max_time: Option<u64>,
|
|
||||||
bytes: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl TimedAction {
|
|
||||||
// Avg returns the average time spent on the action.
|
|
||||||
pub fn avg(&self) -> Option<Duration> {
|
|
||||||
if self.count == 0 {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
Some(Duration::from_nanos(self.acc_time / self.count))
|
|
||||||
}
|
|
||||||
|
|
||||||
// AvgBytes returns the average bytes processed.
|
|
||||||
pub fn avg_bytes(&self) -> u64 {
|
|
||||||
if self.count == 0 {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
self.bytes / self.count
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge other into t.
|
|
||||||
pub fn merge(&mut self, other: TimedAction) {
|
|
||||||
self.count += other.count;
|
|
||||||
self.acc_time += other.acc_time;
|
|
||||||
self.bytes += other.bytes;
|
|
||||||
|
|
||||||
if self.count == 0 {
|
|
||||||
self.min_time = other.min_time;
|
|
||||||
}
|
|
||||||
if let Some(other_min) = other.min_time {
|
|
||||||
self.min_time = self.min_time.map_or(Some(other_min), |min| Some(min.min(other_min)));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.max_time = self
|
|
||||||
.max_time
|
|
||||||
.map_or(other.max_time, |max| Some(max.max(other.max_time.unwrap_or(0))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
enum SizeCategory {
|
|
||||||
SizeLessThan1KiB = 0,
|
|
||||||
SizeLessThan1MiB,
|
|
||||||
SizeLessThan10MiB,
|
|
||||||
SizeLessThan100MiB,
|
|
||||||
SizeLessThan1GiB,
|
|
||||||
SizeGreaterThan1GiB,
|
|
||||||
// Add new entries here
|
|
||||||
SizeLastElemMarker,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Display for SizeCategory {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
let s = match *self {
|
|
||||||
SizeCategory::SizeLessThan1KiB => "SizeLessThan1KiB",
|
|
||||||
SizeCategory::SizeLessThan1MiB => "SizeLessThan1MiB",
|
|
||||||
SizeCategory::SizeLessThan10MiB => "SizeLessThan10MiB",
|
|
||||||
SizeCategory::SizeLessThan100MiB => "SizeLessThan100MiB",
|
|
||||||
SizeCategory::SizeLessThan1GiB => "SizeLessThan1GiB",
|
|
||||||
SizeCategory::SizeGreaterThan1GiB => "SizeGreaterThan1GiB",
|
|
||||||
SizeCategory::SizeLastElemMarker => "SizeLastElemMarker",
|
|
||||||
};
|
|
||||||
write!(f, "{s}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Copy)]
|
#[derive(Clone, Debug, Default, Copy)]
|
||||||
pub struct AccElem {
|
pub struct AccElem {
|
||||||
pub total: u64,
|
pub total: u64,
|
||||||
|
|||||||
@@ -92,15 +92,11 @@ pub const NOTIFY_SUB_SYSTEMS: &[&str] = &[
|
|||||||
pub const NOTIFY_KAFKA_SUB_SYS: &str = "notify_kafka";
|
pub const NOTIFY_KAFKA_SUB_SYS: &str = "notify_kafka";
|
||||||
pub const NOTIFY_MQTT_SUB_SYS: &str = "notify_mqtt";
|
pub const NOTIFY_MQTT_SUB_SYS: &str = "notify_mqtt";
|
||||||
pub const NOTIFY_MYSQL_SUB_SYS: &str = "notify_mysql";
|
pub const NOTIFY_MYSQL_SUB_SYS: &str = "notify_mysql";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const NOTIFY_NATS_SUB_SYS: &str = "notify_nats";
|
pub const NOTIFY_NATS_SUB_SYS: &str = "notify_nats";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const NOTIFY_NSQ_SUB_SYS: &str = "notify_nsq";
|
pub const NOTIFY_NSQ_SUB_SYS: &str = "notify_nsq";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const NOTIFY_ES_SUB_SYS: &str = "notify_elasticsearch";
|
pub const NOTIFY_ES_SUB_SYS: &str = "notify_elasticsearch";
|
||||||
pub const NOTIFY_AMQP_SUB_SYS: &str = "notify_amqp";
|
pub const NOTIFY_AMQP_SUB_SYS: &str = "notify_amqp";
|
||||||
pub const NOTIFY_POSTGRES_SUB_SYS: &str = "notify_postgres";
|
pub const NOTIFY_POSTGRES_SUB_SYS: &str = "notify_postgres";
|
||||||
#[allow(dead_code)]
|
|
||||||
pub const NOTIFY_REDIS_SUB_SYS: &str = "notify_redis";
|
pub const NOTIFY_REDIS_SUB_SYS: &str = "notify_redis";
|
||||||
pub const NOTIFY_REDIS_DEFAULT_CHANNEL: &str = "rustfs_notify_channel";
|
pub const NOTIFY_REDIS_DEFAULT_CHANNEL: &str = "rustfs_notify_channel";
|
||||||
pub const NOTIFY_PULSAR_SUB_SYS: &str = "notify_pulsar";
|
pub const NOTIFY_PULSAR_SUB_SYS: &str = "notify_pulsar";
|
||||||
|
|||||||
@@ -647,7 +647,6 @@ async fn test_multipart_upload_with_sse_c(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Test large multipart upload to verify streaming encryption works correctly
|
/// Test large multipart upload to verify streaming encryption works correctly
|
||||||
#[allow(dead_code)]
|
|
||||||
async fn test_large_multipart_upload(
|
async fn test_large_multipart_upload(
|
||||||
s3_client: &aws_sdk_s3::Client,
|
s3_client: &aws_sdk_s3::Client,
|
||||||
bucket: &str,
|
bucket: &str,
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ impl TestCategory {}
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct TestDefinition {
|
pub struct TestDefinition {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
#[allow(dead_code)]
|
|
||||||
pub category: TestCategory,
|
pub category: TestCategory,
|
||||||
pub is_critical: bool,
|
pub is_critical: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -581,14 +581,6 @@ impl PriorityHealQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a request with the same key already exists in the queue
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn contains_key(&self, request: &HealRequest) -> bool {
|
|
||||||
let key = Self::make_dedup_key(request);
|
|
||||||
self.dedup_keys.contains_key(&key)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Check if an erasure set heal request for a specific set_disk_id exists
|
/// Check if an erasure set heal request for a specific set_disk_id exists
|
||||||
fn contains_erasure_set(&self, set_disk_id: &str) -> bool {
|
fn contains_erasure_set(&self, set_disk_id: &str) -> bool {
|
||||||
let key = format!("erasure_set:{set_disk_id}");
|
let key = format!("erasure_set:{set_disk_id}");
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ pub struct HealLifecycleExpiryContext {
|
|||||||
|
|
||||||
enum HealLifecycleExpiryContextInner {
|
enum HealLifecycleExpiryContextInner {
|
||||||
Ecstore(EcstoreHealLifecycleExpiryContext),
|
Ecstore(EcstoreHealLifecycleExpiryContext),
|
||||||
#[allow(dead_code)]
|
#[allow(
|
||||||
|
dead_code,
|
||||||
|
reason = "constructed by the #[cfg(test)] `test()` helper; the lib target cannot see test-only consumers (backlog#1823)"
|
||||||
|
)]
|
||||||
Test,
|
Test,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ use hyper::Uri;
|
|||||||
use crate::{trace::TraceType, utils::parse_duration};
|
use crate::{trace::TraceType, utils::parse_duration};
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct ServiceTraceOpts {
|
pub struct ServiceTraceOpts {
|
||||||
s3: bool,
|
s3: bool,
|
||||||
internal: bool,
|
internal: bool,
|
||||||
@@ -41,7 +40,6 @@ pub struct ServiceTraceOpts {
|
|||||||
threshold: Duration,
|
threshold: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl ServiceTraceOpts {
|
impl ServiceTraceOpts {
|
||||||
pub fn trace_types(&self) -> TraceType {
|
pub fn trace_types(&self) -> TraceType {
|
||||||
let mut tt = TraceType::default();
|
let mut tt = TraceType::default();
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
use std::io::IsTerminal;
|
use std::io::IsTerminal;
|
||||||
use tracing_subscriber::{EnvFilter, fmt, prelude::*, util::SubscriberInitExt};
|
use tracing_subscriber::{EnvFilter, fmt, prelude::*, util::SubscriberInitExt};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn main() {
|
fn main() {
|
||||||
init_logger(LogLevel::Info);
|
init_logger(LogLevel::Info);
|
||||||
tracing::info!("Tracing logger initialized with Info level");
|
tracing::info!("Tracing logger initialized with Info level");
|
||||||
|
|||||||
@@ -46,15 +46,6 @@ pub struct DefaultLogicalOptimizer {
|
|||||||
analyzer: AnalyzerRef,
|
analyzer: AnalyzerRef,
|
||||||
rules: Vec<Arc<dyn OptimizerRule + Send + Sync>>,
|
rules: Vec<Arc<dyn OptimizerRule + Send + Sync>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DefaultLogicalOptimizer {
|
|
||||||
#[allow(dead_code)]
|
|
||||||
fn with_optimizer_rules(mut self, rules: Vec<Arc<dyn OptimizerRule + Send + Sync>>) -> Self {
|
|
||||||
self.rules = rules;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for DefaultLogicalOptimizer {
|
impl Default for DefaultLogicalOptimizer {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let analyzer = Arc::new(DefaultAnalyzer::default());
|
let analyzer = Arc::new(DefaultAnalyzer::default());
|
||||||
|
|||||||
@@ -36,21 +36,9 @@ pub struct DefaultPhysicalPlanner {
|
|||||||
ext_physical_optimizer_rules: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>,
|
ext_physical_optimizer_rules: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DefaultPhysicalPlanner {
|
impl DefaultPhysicalPlanner {}
|
||||||
#[allow(dead_code)]
|
|
||||||
fn with_physical_transform_rules(mut self, rules: Vec<Arc<dyn ExtensionPlanner + Send + Sync>>) -> Self {
|
|
||||||
self.ext_physical_transform_rules = rules;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DefaultPhysicalPlanner {
|
impl DefaultPhysicalPlanner {}
|
||||||
#[allow(dead_code)]
|
|
||||||
fn with_optimizer_rules(mut self, rules: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>) -> Self {
|
|
||||||
self.ext_physical_optimizer_rules = rules;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for DefaultPhysicalPlanner {
|
impl Default for DefaultPhysicalPlanner {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use s3s::Body;
|
|||||||
|
|
||||||
const STREAMING_SIGN_ALGORITHM: &str = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD";
|
const STREAMING_SIGN_ALGORITHM: &str = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD";
|
||||||
const STREAMING_SIGN_TRAILER_ALGORITHM: &str = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD-TRAILER";
|
const STREAMING_SIGN_TRAILER_ALGORITHM: &str = "STREAMING-AWS4-HMAC-SHA256-PAYLOAD-TRAILER";
|
||||||
const STREAMING_PAYLOAD_HDR: &str = "AWS4-HMAC-SHA256-PAYLOAD";
|
const _STREAMING_PAYLOAD_HDR: &str = "AWS4-HMAC-SHA256-PAYLOAD";
|
||||||
const _STREAMING_TRAILER_HDR: &str = "AWS4-HMAC-SHA256-TRAILER";
|
const _STREAMING_TRAILER_HDR: &str = "AWS4-HMAC-SHA256-TRAILER";
|
||||||
const _PAYLOAD_CHUNK_SIZE: i64 = 64 * 1024;
|
const _PAYLOAD_CHUNK_SIZE: i64 = 64 * 1024;
|
||||||
const _CHUNK_SIGCONST_LEN: i64 = 17;
|
const _CHUNK_SIGCONST_LEN: i64 = 17;
|
||||||
@@ -51,15 +51,14 @@ fn streaming_fail(request: request::Request<Body>, error: SignV4Error) -> Stream
|
|||||||
Err(Box::new(StreamingSignFailure { request, error }))
|
Err(Box::new(StreamingSignFailure { request, error }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
fn _try_build_chunk_string_to_sign(
|
||||||
fn try_build_chunk_string_to_sign(
|
|
||||||
t: OffsetDateTime,
|
t: OffsetDateTime,
|
||||||
region: &str,
|
region: &str,
|
||||||
previous_sig: &str,
|
previous_sig: &str,
|
||||||
chunk_check_sum: &str,
|
chunk_check_sum: &str,
|
||||||
) -> Result<String, SignV4Error> {
|
) -> Result<String, SignV4Error> {
|
||||||
let mut string_to_sign_parts = <Vec<String>>::new();
|
let mut string_to_sign_parts = <Vec<String>>::new();
|
||||||
string_to_sign_parts.push(STREAMING_PAYLOAD_HDR.to_string());
|
string_to_sign_parts.push(_STREAMING_PAYLOAD_HDR.to_string());
|
||||||
let format = format_description!("[year][month][day]T[hour][minute][second]Z");
|
let format = format_description!("[year][month][day]T[hour][minute][second]Z");
|
||||||
string_to_sign_parts.push(
|
string_to_sign_parts.push(
|
||||||
t.format(&format)
|
t.format(&format)
|
||||||
@@ -79,7 +78,7 @@ fn _try_build_chunk_signature(
|
|||||||
previous_signature: &str,
|
previous_signature: &str,
|
||||||
secret_access_key: &str,
|
secret_access_key: &str,
|
||||||
) -> Result<String, SignV4Error> {
|
) -> Result<String, SignV4Error> {
|
||||||
let chunk_string_to_sign = try_build_chunk_string_to_sign(req_time, region, previous_signature, chunk_check_sum)?;
|
let chunk_string_to_sign = _try_build_chunk_string_to_sign(req_time, region, previous_signature, chunk_check_sum)?;
|
||||||
let signing_key = get_signing_key(secret_access_key, region, req_time, SERVICE_TYPE_S3);
|
let signing_key = get_signing_key(secret_access_key, region, req_time, SERVICE_TYPE_S3);
|
||||||
Ok(get_signature(signing_key, &chunk_string_to_sign))
|
Ok(get_signature(signing_key, &chunk_string_to_sign))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user