Skip to content

Commit c7d4023

Browse files
committed
Fix CI: formatting and clippy dead_code warnings
- Run cargo fmt to fix line-length formatting issues - Add #[allow(dead_code)] to unused but intentionally kept items: - circuit_breaker.rs: stats() and CircuitBreakerStats - error.rs: ProxyError enum (some variants for future use) - listener.rs: TLS/H2C bind methods and protocol accessors - metrics.rs: Metrics struct fields and unused metric methods
1 parent 00c8029 commit c7d4023

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

src/circuit_breaker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ impl CircuitBreaker {
179179
}
180180

181181
/// Returns statistics about the circuit breaker.
182+
#[allow(dead_code)]
182183
pub fn stats(&self) -> CircuitBreakerStats {
183184
CircuitBreakerStats {
184185
total_requests: self.total_requests.load(Ordering::Relaxed),
@@ -200,6 +201,7 @@ impl CircuitBreaker {
200201

201202
/// Statistics for the circuit breaker.
202203
#[derive(Debug, Clone)]
204+
#[allow(dead_code)]
203205
pub struct CircuitBreakerStats {
204206
pub total_requests: usize,
205207
pub total_failures: usize,

src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use thiserror::Error;
55

66
/// Errors that can occur during proxy operations.
77
#[derive(Error, Debug)]
8+
#[allow(dead_code)]
89
pub enum ProxyError {
910
/// Failed to bind to the listener address.
1011
#[error("failed to bind listener to {addr}: {source}")]

src/listener.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl Listener {
110110
///
111111
/// Returns `ProxyError::ListenerBind` if binding fails or
112112
/// `ProxyError::TlsConfig` if TLS configuration is invalid.
113+
#[allow(dead_code)]
113114
#[instrument(level = "info", skip(upstream_addrs, tls_config))]
114115
pub async fn bind_with_tls(
115116
addr: &str,
@@ -149,6 +150,7 @@ impl Listener {
149150
///
150151
/// This enables HTTP/2 without TLS, using prior knowledge that the
151152
/// client will speak HTTP/2.
153+
#[allow(dead_code)]
152154
#[instrument(level = "info", skip(upstream_addrs))]
153155
pub async fn bind_h2c(
154156
addr: &str,
@@ -186,11 +188,13 @@ impl Listener {
186188
}
187189

188190
/// Returns whether TLS is enabled.
191+
#[allow(dead_code)]
189192
pub fn is_tls_enabled(&self) -> bool {
190193
self.tls_acceptor.is_some()
191194
}
192195

193196
/// Returns the default HTTP protocol.
197+
#[allow(dead_code)]
194198
pub fn default_protocol(&self) -> HttpProtocol {
195199
self.default_protocol
196200
}

src/metrics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static METRICS: Lazy<Arc<Mutex<Metrics>>> = Lazy::new(|| Arc::new(Mutex::new(Met
6060
///
6161
/// Tracks request counts, latencies, circuit breaker states, rate limits,
6262
/// and connection statistics following RED methodology.
63+
#[allow(dead_code)]
6364
pub struct Metrics {
6465
registry: Registry,
6566
// Request metrics (RED)
@@ -199,13 +200,15 @@ impl Metrics {
199200
}
200201

201202
/// Increments the in-flight request counter.
203+
#[allow(dead_code)]
202204
pub fn inc_requests_in_flight() {
203205
if let Ok(metrics) = METRICS.lock() {
204206
metrics.requests_in_flight.inc();
205207
}
206208
}
207209

208210
/// Decrements the in-flight request counter.
211+
#[allow(dead_code)]
209212
pub fn dec_requests_in_flight() {
210213
if let Ok(metrics) = METRICS.lock() {
211214
metrics.requests_in_flight.dec();
@@ -251,6 +254,7 @@ impl Metrics {
251254
/// # Arguments
252255
///
253256
/// * `limit_type` - The type of limit (global, per_client)
257+
#[allow(dead_code)]
254258
pub fn record_rate_limit_rejection(limit_type: &str) {
255259
let labels = RateLimitLabels {
256260
limit_type: limit_type.to_string(),
@@ -269,6 +273,7 @@ impl Metrics {
269273
/// # Arguments
270274
///
271275
/// * `state` - The connection state (accepted, rejected, closed)
276+
#[allow(dead_code)]
272277
pub fn record_connection(state: &str) {
273278
let labels = ConnectionLabels {
274279
state: state.to_string(),
@@ -280,6 +285,7 @@ impl Metrics {
280285
}
281286

282287
/// Sets the number of active connections.
288+
#[allow(dead_code)]
283289
pub fn set_active_connections(count: i64) {
284290
if let Ok(metrics) = METRICS.lock() {
285291
metrics.connections_active.set(count);

src/service.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ impl ProxyService {
310310
"upstream returned server error"
311311
);
312312
circuit_breaker.record_failure().await;
313-
self.maybe_record_circuit_trip(&upstream_owned, &circuit_breaker).await;
313+
self.maybe_record_circuit_trip(&upstream_owned, &circuit_breaker)
314+
.await;
314315
} else {
315316
info!(
316317
method = %method,
@@ -323,7 +324,8 @@ impl ProxyService {
323324
}
324325

325326
// Update circuit breaker metrics after state may have changed
326-
self.record_circuit_breaker_metrics(&upstream_owned, &circuit_breaker).await;
327+
self.record_circuit_breaker_metrics(&upstream_owned, &circuit_breaker)
328+
.await;
327329

328330
Metrics::record_request(&method, status, &upstream_owned, duration);
329331

@@ -339,8 +341,10 @@ impl ProxyService {
339341
"upstream connection failed"
340342
);
341343
circuit_breaker.record_failure().await;
342-
self.maybe_record_circuit_trip(&upstream_owned, &circuit_breaker).await;
343-
self.record_circuit_breaker_metrics(&upstream_owned, &circuit_breaker).await;
344+
self.maybe_record_circuit_trip(&upstream_owned, &circuit_breaker)
345+
.await;
346+
self.record_circuit_breaker_metrics(&upstream_owned, &circuit_breaker)
347+
.await;
344348

345349
let duration = start.elapsed().as_secs_f64();
346350
Metrics::record_request(&method, 502, &upstream_owned, duration);
@@ -357,8 +361,10 @@ impl ProxyService {
357361
"upstream request timed out"
358362
);
359363
circuit_breaker.record_failure().await;
360-
self.maybe_record_circuit_trip(&upstream_owned, &circuit_breaker).await;
361-
self.record_circuit_breaker_metrics(&upstream_owned, &circuit_breaker).await;
364+
self.maybe_record_circuit_trip(&upstream_owned, &circuit_breaker)
365+
.await;
366+
self.record_circuit_breaker_metrics(&upstream_owned, &circuit_breaker)
367+
.await;
362368

363369
let duration = start.elapsed().as_secs_f64();
364370
Metrics::record_request(&method, 504, &upstream_owned, duration);

0 commit comments

Comments
 (0)