Skip to content

Commit

Permalink
refactor!: made sure that KAFKA_PORT/ZOOKEEPER_PORT follow the co…
Browse files Browse the repository at this point in the history
…nvention of being a `ContainerPort`

This reverts commit 1c6ba59.
  • Loading branch information
CommanderStorm committed Aug 21, 2024
1 parent 37180a7 commit 2533ac3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/kafka/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const TAG: &str = "6.1.1";
/// Can be rebound externally via [`testcontainers::core::ImageExt::with_mapped_port`]
///
/// [`Kafka`]: https://kafka.apache.org/
pub const KAFKA_PORT: u16 = 9093;
pub const KAFKA_PORT: ContainerPort = ContainerPort::Tcp(9093);
/// Port that the [`Zookeeper`] part of the container has internally
/// Can be rebound externally via [`testcontainers::core::ImageExt::with_mapped_port`]
///
Expand All @@ -33,7 +33,10 @@ impl Default for Kafka {
);
env_vars.insert(
"KAFKA_LISTENERS".to_owned(),
format!("PLAINTEXT://0.0.0.0:{KAFKA_PORT},BROKER://0.0.0.0:9092"),
format!(
"PLAINTEXT://0.0.0.0:{KAFKA_PORT},BROKER://0.0.0.0:9092",
KAFKA_PORT = KAFKA_PORT.as_u16()
),
);
env_vars.insert(
"KAFKA_LISTENER_SECURITY_PROTOCOL_MAP".to_owned(),
Expand Down Expand Up @@ -95,7 +98,7 @@ zookeeper-server-start zookeeper.properties &
}

fn expose_ports(&self) -> &[ContainerPort] {
&[ContainerPort::Tcp(KAFKA_PORT)]
&[KAFKA_PORT]
}

fn exec_after_start(
Expand All @@ -115,7 +118,7 @@ zookeeper-server-start zookeeper.properties &
"--add-config".to_string(),
format!(
"advertised.listeners=[PLAINTEXT://127.0.0.1:{},BROKER://localhost:9092]",
cs.host_port_ipv4(ContainerPort::Tcp(KAFKA_PORT))?
cs.host_port_ipv4(KAFKA_PORT)?
),
];
let ready_conditions = vec![WaitFor::message_on_stdout(
Expand Down

0 comments on commit 2533ac3

Please # to comment.