InfluxElixir.Config (InfluxElixir v0.1.16)

Copy Markdown View Source

Connection configuration validation and defaults.

Uses NimbleOptions to validate connection options passed to InfluxElixir.ConnectionSupervisor and consumed by client implementations.

Options

  • :host - InfluxDB host (e.g., "localhost" or "us-east-1.influxdb.io") Required.
  • :token - Authentication token. Required.
  • :org - Organization name (default: "")
  • :database - Default database name (default: nil)
  • :databases - List of database names (informational; LocalClient pre-creates them, HTTP defaults :database to the first item if :database is not set). Default: []
  • :port - Port number (default: 8086)
  • :scheme - :http or :https (default: :https)
  • :pool_size - Finch connection pool size (default: 10)

Example

iex> InfluxElixir.Config.validate!(
...>   host: "localhost",
...>   token: "my-token",
...>   scheme: :http,
...>   port: 8086
...> )

Summary

Functions

Builds the base URL from validated config options.

Validates connection options and returns a normalized keyword list.

Validates connection options, raising on error.

Functions

base_url(opts)

@spec base_url(keyword()) :: binary()

Builds the base URL from validated config options.

Examples

iex> InfluxElixir.Config.base_url(scheme: :https, host: "example.com", port: 443)
"https://example.com:443"

validate(opts)

@spec validate(keyword()) ::
  {:ok, keyword()} | {:error, NimbleOptions.ValidationError.t()}

Validates connection options and returns a normalized keyword list.

Returns {:ok, validated_opts} or {:error, %NimbleOptions.ValidationError{}}.

Examples

iex> {:ok, opts} = InfluxElixir.Config.validate(
...>   host: "localhost",
...>   token: "my-token"
...> )
iex> opts[:scheme]
:https

validate!(opts)

@spec validate!(keyword()) :: keyword()

Validates connection options, raising on error.

Returns the validated keyword list or raises NimbleOptions.ValidationError.

Examples

iex> opts = InfluxElixir.Config.validate!(
...>   host: "localhost",
...>   token: "my-token"
...> )
iex> opts[:port]
8086