WeaviateEx.GRPC.Services.Health (WeaviateEx v0.7.4)

View Source

gRPC Health service for health checks.

This module provides functions for checking the health status of the Weaviate gRPC server.

Usage

{:ok, channel} = WeaviateEx.GRPC.Channel.connect(config)

{:ok, :serving} = Health.check(channel)
# or
{:error, :not_serving} = Health.check(channel)

Summary

Functions

Check the health status of the Weaviate gRPC server.

Check if the server is healthy (returns boolean).

Ping the gRPC server to verify connectivity.

Wait for the server to become healthy.

Types

health_opts()

@type health_opts() :: [timeout: non_neg_integer(), service: String.t()]

Functions

check(channel, opts \\ [])

@spec check(GRPC.Channel.t(), health_opts()) ::
  {:ok, :serving} | {:error, WeaviateEx.Error.t()}

Check the health status of the Weaviate gRPC server.

Returns :serving if the server is healthy, otherwise an error.

Options

  • :timeout - Request timeout in milliseconds (default: 5000)
  • :service - Service name to check (default: "")

Examples

{:ok, :serving} = Health.check(channel)
{:error, %Error{type: :service_unavailable}} = Health.check(channel)

healthy?(channel, opts \\ [])

@spec healthy?(GRPC.Channel.t(), health_opts()) :: boolean()

Check if the server is healthy (returns boolean).

Examples

true = Health.healthy?(channel)
false = Health.healthy?(channel)

ping(channel, opts \\ [])

@spec ping(
  GRPC.Channel.t() | nil,
  keyword()
) :: :ok | {:error, term()}

Ping the gRPC server to verify connectivity.

This is a lightweight check that returns :ok if the server responds, {:error, reason} otherwise. Use this for quick connection verification at startup or for heartbeat checks.

Options

  • :timeout - Request timeout in milliseconds (default: 5000)

Examples

:ok = Health.ping(channel)
{:error, reason} = Health.ping(nil)

wait_for_ready(channel, opts \\ [])

@spec wait_for_ready(
  GRPC.Channel.t(),
  keyword()
) :: :ok | {:error, :timeout | WeaviateEx.Error.t()}

Wait for the server to become healthy.

Polls the health endpoint until the server is serving or timeout is reached.

Options

  • :timeout - Total timeout in milliseconds (default: 30000)
  • :interval - Polling interval in milliseconds (default: 1000)

Examples

:ok = Health.wait_for_ready(channel, timeout: 60_000)
{:error, :timeout} = Health.wait_for_ready(channel, timeout: 5_000)