WeaviateEx.Client.Pool (WeaviateEx v0.7.4)

View Source

Connection pool configuration for HTTP and gRPC connections.

Provides configuration structs for managing connection pools to optimize performance and resource usage.

Example

# Create custom pool config
http_pool = Pool.new(size: 20, overflow: 10, timeout: 10_000)

# Use with client creation
{:ok, client} = Client.new(
  base_url: "http://localhost:8080",
  http_pool: http_pool
)

# Or use presets
{:ok, client} = Client.new(
  base_url: "http://localhost:8080",
  http_pool: Pool.default_http(),
  grpc_pool: Pool.default_grpc()
)

Summary

Functions

Returns default pool configuration.

Returns default pool configuration optimized for gRPC connections.

Returns default pool configuration optimized for HTTP/Finch connections.

Create a new pool configuration.

Convert pool configuration to Finch pool options.

Convert pool configuration to gRPC channel options.

Types

strategy()

@type strategy() :: :fifo | :lifo

t()

@type t() :: %WeaviateEx.Client.Pool{
  idle_timeout: pos_integer(),
  max_age: pos_integer() | nil,
  overflow: non_neg_integer(),
  size: pos_integer(),
  strategy: strategy(),
  timeout: pos_integer()
}

Functions

default()

@spec default() :: t()

Returns default pool configuration.

Example

pool = Pool.default()

default_grpc()

@spec default_grpc() :: t()

Returns default pool configuration optimized for gRPC connections.

gRPC connections are multiplexed, so fewer connections are typically needed.

Example

pool = Pool.default_grpc()

default_http()

@spec default_http() :: t()

Returns default pool configuration optimized for HTTP/Finch connections.

HTTP pools typically benefit from more connections for parallel requests.

Example

pool = Pool.default_http()

new(opts \\ [])

@spec new(keyword()) :: t()

Create a new pool configuration.

Options

  • :size - Number of connections in the pool (default: 10)
  • :overflow - Maximum overflow connections (default: 5)
  • :strategy - Connection selection strategy, :fifo or :lifo (default: :lifo)
  • :timeout - Checkout timeout in milliseconds (default: 5000)
  • :idle_timeout - Idle connection timeout in milliseconds (default: 60000)
  • :max_age - Maximum connection age before recycling (default: nil, no limit)

Example

Pool.new(size: 20, overflow: 10, timeout: 10_000)

to_finch_opts(pool)

@spec to_finch_opts(t()) :: keyword()

Convert pool configuration to Finch pool options.

Example

opts = Pool.to_finch_opts(pool)
# Returns: [size: 10, count: 1]

to_grpc_opts(pool)

@spec to_grpc_opts(t()) :: keyword()

Convert pool configuration to gRPC channel options.

Example

opts = Pool.to_grpc_opts(pool)