View Source OpenApiTypesense.Connection (OpenApiTypesense v0.5.1)

Fetches credentials either from application env or map.

Summary

Functions

Setting new connection or using the default config.

Types

t()

(since 0.2.0)
@type t() :: %{
  host: binary() | nil,
  api_key: binary() | nil,
  port: non_neg_integer() | nil,
  scheme: binary() | nil,
  client: list() | nil
}

Functions

new()

(since 0.2.0)
@spec new() :: %OpenApiTypesense.Connection{
  api_key: term(),
  client: term(),
  host: term(),
  port: term(),
  scheme: term()
}

Setting new connection or using the default config.

On using this function

Functions e.g. OpenApiTypesense.Health.health/0 don't need to explicitly pass this unless you want to use another connection. Also, api_key is hidden when invoking this function.

Examples

iex> alias OpenApiTypesense.Connection
...> Connection.new()
%OpenApiTypesense.Connection{
  host: "localhost",
  port: 8108,
  scheme: "http",
  api_key: "xyz"
}

iex> alias OpenApiTypesense.Connection
...> Connection.new(%{})
** (ArgumentError) Missing required fields: [:api_key, :host, :port, :scheme]

new(connection)

(since 0.2.0)
@spec new(t() | map()) :: %OpenApiTypesense.Connection{
  api_key: term(),
  client: term(),
  host: term(),
  port: term(),
  scheme: term()
}