PortWaitStrategy class

Waits until a TCP connection to the specified port can be established.

Attempts a Socket.connect to the container's mapped host port with a 1-second timeout per attempt. SocketException and TimeoutException are treated as transient failures.

Example:

container
  ..withExposedPorts([5432])
  ..waitingFor(PortWaitStrategy(5432));
Inheritance

Constructors

PortWaitStrategy(int port)
Creates a PortWaitStrategy that probes port.

Properties

hashCode int
The hash code for this object.
no setterinherited
pollInterval Duration
Time between successive polling attempts.
getter/setter pairinherited
port int
The container port to probe for TCP connectivity.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startupTimeout Duration
Maximum time to wait for the container to become ready.
getter/setter pairinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
poll(Future<bool> check(), {List<Type>? transientExceptions}) Future<bool>
Adaptive polling loop.
inherited
toString() String
A string representation of this object.
inherited
waitUntilReady(WaitStrategyTarget target) Future<void>
Attempts a TCP connection to port on each poll cycle.
override
withPollInterval(Duration interval) WaitStrategy
Sets the poll interval between readiness checks.
inherited
withStartupTimeout(Duration timeout) WaitStrategy
Sets the maximum startup timeout.
inherited
withTransientExceptions(List<Type> exceptions) WaitStrategy
Adds exceptions to the set of exception types that are treated as transient failures during polling.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited