Skip to content

Commit 84f1559

Browse files
committed
Audit and clean up dead_code annotations
- Remove stale #[allow(dead_code)] from distribution module in lib.rs (the module is actively used) - Remove unused node_name_atom field from DistributionManager (redundant with crate::core::node::node_name_atom()) - Add targeted annotations to public API methods that are intentionally exposed but not used internally (native_nodes, node_type, erlang_nodes, node_name_atom, node_name, creation) - Add annotations to transport infrastructure (RecvStream trait, QuicRecvStream, TcpRecvStream) reserved for multi-stream support - Add annotations to test utilities (arb_pid_node2_restarted, SyncResponse)
1 parent 5faeab8 commit 84f1559

6 files changed

Lines changed: 14 additions & 7 deletions

File tree

crates/ambitious/src/distribution/manager.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ pub struct ErlangNodeHandle {
4646
info: NodeInfo,
4747
/// Sender for outgoing ETF-encoded messages with destination info.
4848
tx: mpsc::Sender<ErlangOutgoingMessage>,
49-
/// Last seen timestamp.
49+
/// Last seen timestamp (for future heartbeat tracking).
50+
#[allow(dead_code)]
5051
last_seen_ms: AtomicU64,
5152
}
5253

@@ -113,8 +114,6 @@ fn current_time_ms() -> u64 {
113114
pub struct DistributionManager {
114115
/// Our node name.
115116
node_name: String,
116-
/// Our node name as an atom.
117-
node_name_atom: Atom,
118117
/// Our creation number.
119118
creation: u32,
120119
/// Connected native nodes by node name atom.
@@ -141,10 +140,8 @@ pub struct DistributionManager {
141140
impl DistributionManager {
142141
/// Create a new distribution manager.
143142
pub fn new(node_name: String, creation: u32) -> Self {
144-
let node_name_atom = Atom::new(&node_name);
145143
Self {
146144
node_name,
147-
node_name_atom,
148145
creation,
149146
nodes: DashMap::new(),
150147
addr_to_node: DashMap::new(),
@@ -413,17 +410,20 @@ impl DistributionManager {
413410
}
414411

415412
/// Get list of connected native nodes only.
413+
#[allow(dead_code)]
416414
pub fn native_nodes(&self) -> Vec<Atom> {
417415
self.nodes.iter().map(|r| *r.key()).collect()
418416
}
419417

420418
/// Get list of connected Erlang nodes only.
421419
#[cfg(feature = "erlang-dist")]
420+
#[allow(dead_code)]
422421
pub fn erlang_nodes(&self) -> Vec<Atom> {
423422
self.erlang_nodes.iter().map(|r| *r.key()).collect()
424423
}
425424

426425
/// Get the type of a connected node.
426+
#[allow(dead_code)]
427427
pub fn node_type(&self, node_atom: Atom) -> Option<NodeType> {
428428
self.node_types.get(&node_atom).map(|r| *r)
429429
}
@@ -619,16 +619,19 @@ impl DistributionManager {
619619
}
620620

621621
/// Get our node name atom.
622+
#[allow(dead_code)]
622623
pub fn node_name_atom(&self) -> Atom {
623-
self.node_name_atom
624+
crate::core::node::node_name_atom()
624625
}
625626

626627
/// Get our node name.
628+
#[allow(dead_code)]
627629
pub fn node_name(&self) -> &str {
628630
&self.node_name
629631
}
630632

631633
/// Get our creation number.
634+
#[allow(dead_code)]
632635
pub fn creation(&self) -> u32 {
633636
self.creation
634637
}

crates/ambitious/src/distribution/tcp_transport.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ impl Transport for TcpTransport {
235235

236236
/// Wrapper for receiving messages from a TCP connection.
237237
pub struct TcpRecvStream {
238+
#[allow(dead_code)]
238239
connection: TcpConnection,
239240
}
240241

crates/ambitious/src/distribution/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fn arb_pid_node2() -> impl Strategy<Value = Pid> {
3333
}
3434

3535
/// Generate a PID from node2 after restart (creation 1)
36+
#[allow(dead_code)]
3637
fn arb_pid_node2_restarted() -> impl Strategy<Value = Pid> {
3738
arb_pid_for_node("node2@localhost", 1)
3839
}
@@ -47,6 +48,7 @@ enum PgOperation {
4748
/// Remove all PIDs from a node (simulates disconnect)
4849
NodeDisconnect { node: String },
4950
/// Apply a sync response (simulates reconnection sync)
51+
#[allow(dead_code)]
5052
SyncResponse {
5153
from_node: String,
5254
groups: Vec<(String, Vec<Pid>)>,

crates/ambitious/src/distribution/traits.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub trait TransportConnection: Send + Sync + Clone + 'static {
7474
}
7575

7676
/// A receive stream for reading additional data after the initial message.
77+
#[allow(dead_code)]
7778
#[async_trait]
7879
pub trait RecvStream: Send + 'static {
7980
/// Receive a message from this stream.

crates/ambitious/src/distribution/transport.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ impl Transport for QuicTransport {
258258
}
259259

260260
/// Wrapper around quinn's RecvStream that implements our RecvStream trait.
261+
#[allow(dead_code)]
261262
pub struct QuicRecvStream {
262263
inner: RecvStream,
263264
}

crates/ambitious/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ pub mod application;
140140
// =============================================================================
141141

142142
/// Distribution layer for connecting Ambitious nodes.
143-
#[allow(dead_code)]
144143
pub mod distribution;
145144

146145
/// Elixir-compatible Node API for distributed Ambitious.

0 commit comments

Comments
 (0)