Milvex.Config
(milvex v0.6.0)
Copy Markdown
Configuration module for Milvus client connections.
Handles parsing and validation of connection parameters from keyword lists, maps, or URI strings. Supports various authentication methods including username/password and API tokens.
Summary
Functions
Returns the default SSL options for secure connections.
Parse and validate configuration from keyword list or map.
Parse configuration from URI string.
Returns the configuration schema.
Types
@type t() :: %{ :timeout => integer(), optional(:port) => integer(), optional(:user) => binary(), :ssl => boolean(), :host => binary(), optional(:token) => binary(), optional(:password) => binary(), ssl_options: any(), database: binary(), reconnect_base_delay: integer(), reconnect_max_delay: integer(), reconnect_multiplier: float(), reconnect_jitter: float(), adapter: any(), adapter_opts: any() }
Functions
@spec default_ssl_options() :: keyword()
Returns the default SSL options for secure connections.
@spec parse(keyword() | map()) :: {:ok, t()} | {:error, Milvex.Error.t()}
Parse and validate configuration from keyword list or map.
Returns {:ok, config} on success or {:error, error} on validation failure.
Examples
iex> Milvex.Config.parse(host: "localhost", port: 19530)
{:ok, %{host: "localhost", port: 19530, ...}}
iex> Milvex.Config.parse(port: -1)
{:error, %Milvex.Errors.Invalid{...}}
@spec parse_uri(String.t()) :: {:ok, t()} | {:error, Milvex.Error.t()}
Parse configuration from URI string.
Supports formats:
http://localhost:19530https://user:pass@host:19530/databasemilvus://host:19530?timeout=60000
Examples
iex> Milvex.Config.parse_uri("http://localhost:19530")
{:ok, %{host: "localhost", port: 19530, ssl: false, ...}}
iex> Milvex.Config.parse_uri("https://user:pass@milvus.example.com:443/mydb")
{:ok, %{host: "milvus.example.com", port: 443, ssl: true, user: "user", ...}}
Returns the configuration schema.
Configuration options for connecting to a Milvus server
Options
:timeout(integer/0) - Required. Timeout for gRPC calls in milliseconds The default value is30000.:port(integer/0) - Milvus server port (1-65535):user(String.t/0) - Username for authentication:ssl(boolean/0) - Required. Enable SSL/TLS encryption The default value isnil.:host(String.t/0) - Required. Milvus server hostname or IP address The default value is"localhost".:token(String.t/0) - API token for authentication (alternative to user/password):password(String.t/0) - Password for authentication:ssl_options(term/0) - Required. SSL options passed to the underlying transport The default value is[].:database(String.t/0) - Required. Database name to connect to The default value is"default".:reconnect_base_delay(integer/0) - Required. Base delay for reconnection attempts in milliseconds The default value is1000.:reconnect_max_delay(integer/0) - Required. Maximum delay for reconnection attempts in milliseconds The default value is60000.:reconnect_multiplier(float/0) - Required. Multiplier for exponential backoff The default value is2.0.:reconnect_jitter(float/0) - Required. Jitter factor (0.0 to 1.0) to randomize delay The default value is0.1.:adapter(term/0) - Required. GRPC client adapter module The default value isGRPC.Client.Adapters.Gun.:adapter_opts(term/0) - Required. Adapter-specific options passed to GRPC.Stub.connect The default value is[].
Example
iex> Zoi.example(Milvex.Config.schema())
%{timeout: 30000, port: 19530, host: "localhost", database: "default"}