Skip to content

Commit ff7d0ad

Browse files
authored
Fix: move test only helpers, remove unnecessary lint suppressions (#2773)
move test only helpers, remove unnecessary lint suppressions public APIs # Change Summary 1. Move test only helpers behind `#[cfg(test)]`, removes unnecessary `#[allow(dead_code)]` 2. Remove unnecessary lint suppressions on public APIs ## What issue does this PR close? Quick lint fixes for code hygiene ## How are these changes tested? Verified using `cargo check` and `cargo test` - `cargo check -p otap-df-channel` - `cargo check -p otap-df-core-nodes` - `cargo test -p otap-df-core-nodes -- syslog` ## Are there any user-facing changes? No
1 parent 8811db4 commit ff7d0ad

2 files changed

Lines changed: 24 additions & 26 deletions

File tree

  • rust/otap-dataflow/crates
    • channel/src
    • core-nodes/src/receivers/syslog_cef_receiver

rust/otap-dataflow/crates/channel/src/mpmc.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ impl<T> Sender<T> {
280280
}
281281

282282
/// Attempts to send a value to the channel (async method).
283-
#[allow(dead_code)]
284283
pub async fn send_async(&self, value: T) -> Result<(), SendError<T>> {
285284
// Fast path: avoid creating/polling a future when there is capacity.
286285
match self.send(value) {
@@ -298,7 +297,6 @@ impl<T> Sender<T> {
298297
}
299298

300299
/// Closes the channel, preventing further sends.
301-
#[allow(dead_code)]
302300
pub fn close(&self) {
303301
let mut state = self.channel.state.borrow_mut();
304302
state.is_closed = true;
@@ -339,7 +337,6 @@ impl<T> Receiver<T> {
339337
}
340338

341339
/// Attempts to receive a value from the channel (async method).
342-
#[allow(dead_code)]
343340
pub async fn recv(&self) -> Result<T, RecvError> {
344341
RecvFuture { receiver: self }.await
345342
}

rust/otap-dataflow/crates/core-nodes/src/receivers/syslog_cef_receiver/mod.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,6 @@ struct Config {
132132
}
133133

134134
impl Config {
135-
/// Creates a new Config for TCP.
136-
#[must_use]
137-
#[allow(dead_code)]
138-
const fn new_tcp(listening_addr: SocketAddr) -> Self {
139-
Self {
140-
protocol: Protocol::Tcp(TcpConfig {
141-
listening_addr,
142-
tls: None,
143-
}),
144-
batch: None,
145-
}
146-
}
147-
148-
/// Creates a new Config for UDP.
149-
#[must_use]
150-
#[allow(dead_code)]
151-
const fn new_udp(listening_addr: SocketAddr) -> Self {
152-
Self {
153-
protocol: Protocol::Udp(UdpConfig { listening_addr }),
154-
batch: None,
155-
}
156-
}
157-
158135
/// Returns the effective max batch duration, using the configured value or the default.
159136
fn max_batch_duration(&self) -> Duration {
160137
self.batch
@@ -1021,6 +998,30 @@ pub struct SyslogCefReceiverMetrics {
1021998
pub tcp_connections_rejected_memory_pressure: Counter<u64>,
1022999
}
10231000

1001+
#[cfg(test)]
1002+
impl Config {
1003+
/// Creates a new Config for TCP. Test-only helper.
1004+
#[must_use]
1005+
const fn new_tcp(listening_addr: SocketAddr) -> Self {
1006+
Self {
1007+
protocol: Protocol::Tcp(TcpConfig {
1008+
listening_addr,
1009+
tls: None,
1010+
}),
1011+
batch: None,
1012+
}
1013+
}
1014+
1015+
/// Creates a new Config for UDP. Test-only helper.
1016+
#[must_use]
1017+
const fn new_udp(listening_addr: SocketAddr) -> Self {
1018+
Self {
1019+
protocol: Protocol::Udp(UdpConfig { listening_addr }),
1020+
batch: None,
1021+
}
1022+
}
1023+
}
1024+
10241025
#[cfg(test)]
10251026
mod tests {
10261027
use super::*;

0 commit comments

Comments
 (0)