Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/testcontainers/community/nats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing_extensions import Self

from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import wait_container_is_ready, wait_for_logs
from testcontainers.core.wait_strategies import LogMessageWaitStrategy


class NatsContainer(DockerContainer):
Expand Down Expand Up @@ -59,10 +59,9 @@ def __init__(
self.with_exposed_ports(self.client_port, self.management_port)
if jetstream:
self.with_command("-js")

@wait_container_is_ready()
def _healthcheck(self) -> None:
wait_for_logs(self, self._expected_ready_log, timeout=self._ready_timeout_secs)
self._wait_strategy = LogMessageWaitStrategy(self._expected_ready_log).with_startup_timeout(
self._ready_timeout_secs
)

def nats_uri(self) -> str:
return f"nats://{self.get_container_host_ip()}:{self.get_exposed_port(self.client_port)}"
Expand All @@ -75,5 +74,4 @@ def nats_management_uri(self) -> str:

def start(self) -> Self:
super().start()
self._healthcheck()
return self