Skip to content

Commit 81d3aa2

Browse files
committed
Add a UntranslatedPeer constructor
This commits adds a constructor for UntranslatedPeer, hidden under nodejs_rs_unstable feature flag. This constructor is needed to allow unit testing of the address translation policies, implemented in that driver.
1 parent 2dec09b commit 81d3aa2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

scylla/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
157157
'cfg(scylla_cloud_tests)',
158158
'cfg(cassandra_tests)',
159159
'cfg(cpp_rust_unstable)',
160+
'cfg(nodejs_rs_unstable)',
160161
'cfg(ccm_tests)',
161162
] }
162163

scylla/src/policies/address_translator.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ impl UntranslatedPeer<'_> {
4949
pub fn rack(&self) -> Option<&str> {
5050
self.rack
5151
}
52+
53+
/// Creates a new untranslated peer. Intended to be used only in nodejs-rs driver only.
54+
/// This specific constructor is intended for unit tests only.
55+
#[cfg(nodejs_rs_unstable)]
56+
pub fn new(address: SocketAddr) -> Self {
57+
UntranslatedPeer {
58+
host_id: Uuid::nil(),
59+
untranslated_address: address,
60+
datacenter: None,
61+
rack: None,
62+
}
63+
}
5264
}
5365

5466
/// Translates IP addresses received from ScyllaDB nodes into locally reachable addresses.

0 commit comments

Comments
 (0)