WeaviateEx.Health (WeaviateEx v0.7.4)
View SourceHealth check utilities for Weaviate connections.
Provides functions to validate connectivity and perform health checks against Weaviate instances with configurable strictness.
Summary
Functions
Check if Weaviate is alive (liveness probe).
Checks connection to Weaviate without raising errors.
Check if Weaviate is ready (readiness probe).
Validates connection to Weaviate with configurable strictness.
Waits for Weaviate to become ready.
Types
Functions
@spec alive?() :: {:ok, boolean()}
@spec alive?(WeaviateEx.Client.t()) :: {:ok, boolean()}
Check if Weaviate is alive (liveness probe).
Uses the /.well-known/live endpoint for Kubernetes compatibility.
Returns {:ok, true} if alive, {:ok, false} otherwise.
With Client
{:ok, true} = Health.alive?(client)Without Client (uses default WeaviateEx config)
{:ok, true} = Health.alive?()This endpoint indicates whether the Weaviate process is running. A failed liveness check means the container should be restarted.
@spec check_connection(Keyword.t()) :: health_result()
Checks connection to Weaviate without raising errors.
Returns {:ok, meta} if connected, {:error, reason} otherwise.
Examples
case WeaviateEx.Health.check_connection() do
{:ok, meta} -> IO.puts("Connected to Weaviate v#{meta["version"]}")
{:error, reason} -> IO.puts("Not connected: #{inspect(reason)}")
end
@spec ready?() :: {:ok, boolean()}
@spec ready?(WeaviateEx.Client.t()) :: {:ok, boolean()}
Check if Weaviate is ready (readiness probe).
Uses the /.well-known/ready endpoint for Kubernetes compatibility.
Returns {:ok, true} if ready, {:ok, false} otherwise.
With Client
{:ok, true} = Health.ready?(client)Without Client (uses default WeaviateEx config)
{:ok, true} = Health.ready?()This endpoint indicates whether Weaviate is ready to receive traffic. A failed readiness check means the container should not receive requests.
Validates connection to Weaviate with configurable strictness.
Options
:strict- (default:true) If true, raises on connection failure. If false, logs a warning and returns the error.:timeout- Connection timeout in milliseconds (default: 5000):retries- Number of retry attempts (default: 0):retry_delay- Delay between retries in milliseconds (default: 1000)
Examples
# Strict mode (default) - raises on failure
WeaviateEx.Health.validate_connection!()
# Relaxed mode - returns error without raising
WeaviateEx.Health.validate_connection!(strict: false)
# With retries
WeaviateEx.Health.validate_connection!(retries: 3, retry_delay: 2000)
@spec wait_until_ready(Keyword.t()) :: :ok | {:error, :timeout}
Waits for Weaviate to become ready.
Useful for startup scripts and testing.
Options
:timeout- Total wait timeout in milliseconds (default: 30000):check_interval- Time between checks in milliseconds (default: 1000)
Examples
# Wait up to 30 seconds
WeaviateEx.Health.wait_until_ready()
# Wait up to 60 seconds with 2 second intervals
WeaviateEx.Health.wait_until_ready(timeout: 60000, check_interval: 2000)