Skip to content

Commit 2b0e349

Browse files
authored
Merge pull request #1466 from adespawn/add-translation-policies-helpers
Add a UntranslatedPeer constructor
2 parents 2dec09b + 194247f commit 2b0e349

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.github/workflows/rust.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ jobs:
5050
- name: Cargo check with cpp_rust_unstable cfg
5151
run: RUSTFLAGS="--cfg cpp_rust_unstable -Dwarnings" cargo clippy --all-targets --all-features
5252

53+
# nodejs_rs_unstable special cfg
54+
- name: Cargo check with nodejs_rs_unstable cfg
55+
run: RUSTFLAGS="--cfg nodejs_rs_unstable -Dwarnings" cargo clippy --all-targets --all-features
56+
5357
# Features checks.
5458
# No features.
5559
- name: Cargo check without features

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)