Skip to content

Commit

Permalink
refactor(rust): add localhost contstructor for StaticHostnamePort
Browse files Browse the repository at this point in the history
  • Loading branch information
Suhodolets Ilya authored and ilyaaay committed Jan 16, 2025
1 parent 2733b3f commit c207225
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 4 additions & 8 deletions implementations/rust/ockam/ockam_command/src/kafka/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ pub(crate) mod outlet;
pub(crate) mod producer;
pub(crate) mod util;

const KAFKA_DEFAULT_BOOTSTRAP_ADDRESS: StaticHostnamePort =
StaticHostnamePort::new("127.0.0.1", 9092);
const KAFKA_DEFAULT_BOOTSTRAP_ADDRESS: StaticHostnamePort = StaticHostnamePort::localhost(9092);
const KAFKA_DEFAULT_PROJECT_ROUTE: &str = "/project/default";
const KAFKA_DEFAULT_CONSUMER_SERVER: StaticHostnamePort =
StaticHostnamePort::new("127.0.0.1", 4000);
const KAFKA_DEFAULT_INLET_BIND_ADDRESS: StaticHostnamePort =
StaticHostnamePort::new("127.0.0.1", 4000);
const KAFKA_DEFAULT_PRODUCER_SERVER: StaticHostnamePort =
StaticHostnamePort::new("127.0.0.1", 5000);
const KAFKA_DEFAULT_CONSUMER_SERVER: StaticHostnamePort = StaticHostnamePort::localhost(4000);
const KAFKA_DEFAULT_INLET_BIND_ADDRESS: StaticHostnamePort = StaticHostnamePort::localhost(4000);
const KAFKA_DEFAULT_PRODUCER_SERVER: StaticHostnamePort = StaticHostnamePort::localhost(5000);

fn kafka_default_outlet_addr() -> String {
DefaultAddress::KAFKA_OUTLET.to_string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ impl StaticHostnamePort {
pub const fn new(hostname: &'static str, port: u16) -> Self {
Self { hostname, port }
}

pub const fn localhost(port: u16) -> Self {
Self {
hostname: "127.0.0.1",
port,
}
}
}

impl TryFrom<StaticHostnamePort> for HostnamePort {
Expand Down

0 comments on commit c207225

Please sign in to comment.