Skip to content

Commit b860ad6

Browse files
author
Suhodolets Ilya
committed
refactor(rust): add localhost contstructor for StaticHostnamePort
1 parent 62f4aff commit b860ad6

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

implementations/rust/ockam/ockam_command/src/kafka/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@ pub(crate) mod outlet;
1111
pub(crate) mod producer;
1212
pub(crate) mod util;
1313

14-
const KAFKA_DEFAULT_BOOTSTRAP_ADDRESS: StaticHostnamePort =
15-
StaticHostnamePort::new("127.0.0.1", 9092);
14+
const KAFKA_DEFAULT_BOOTSTRAP_ADDRESS: StaticHostnamePort = StaticHostnamePort::localhost(9092);
1615
const KAFKA_DEFAULT_PROJECT_ROUTE: &str = "/project/default";
17-
const KAFKA_DEFAULT_CONSUMER_SERVER: StaticHostnamePort =
18-
StaticHostnamePort::new("127.0.0.1", 4000);
19-
const KAFKA_DEFAULT_INLET_BIND_ADDRESS: StaticHostnamePort =
20-
StaticHostnamePort::new("127.0.0.1", 4000);
21-
const KAFKA_DEFAULT_PRODUCER_SERVER: StaticHostnamePort =
22-
StaticHostnamePort::new("127.0.0.1", 5000);
16+
const KAFKA_DEFAULT_CONSUMER_SERVER: StaticHostnamePort = StaticHostnamePort::localhost(4000);
17+
const KAFKA_DEFAULT_INLET_BIND_ADDRESS: StaticHostnamePort = StaticHostnamePort::localhost(4000);
18+
const KAFKA_DEFAULT_PRODUCER_SERVER: StaticHostnamePort = StaticHostnamePort::localhost(5000);
2319

2420
fn kafka_default_outlet_addr() -> String {
2521
DefaultAddress::KAFKA_OUTLET.to_string()

implementations/rust/ockam/ockam_transport_core/src/hostname_port.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ impl StaticHostnamePort {
2121
pub const fn new(hostname: &'static str, port: u16) -> Self {
2222
Self { hostname, port }
2323
}
24+
25+
pub const fn localhost(port: u16) -> Self {
26+
Self {
27+
hostname: "127.0.0.1",
28+
port,
29+
}
30+
}
2431
}
2532

2633
impl TryFrom<StaticHostnamePort> for HostnamePort {

0 commit comments

Comments
 (0)