Validated connection configuration.
You normally never build this yourself — pass the options below to
TypeDB.start_link/1 and they are validated into a %TypeDB.Config{}.
Options
:url— server URL, e.g."http://localhost:8000". A bare"host:port"or"host"is accepted and defaults tohttp. Defaults to"http://localhost:8000".:username/:password— credentials used againstPOST /v1/signin. Required unless:tokenis given.:token— a pre-issued bearer token, used instead of signing in. When the token expires it cannot be renewed, so prefer credentials for long-lived connections.:name— registered name of the connection process. Defaults toTypeDB.:timeout— per-request receive timeout in ms. Defaults to60_000.:connect_timeout— TCP/TLS connect timeout in ms. Defaults to10_000.:http—{adapter_module, adapter_opts}. Defaults to{TypeDB.HTTP.Finch, []}. SeeTypeDB.HTTPfor the alternatives and why this is the default.:max_retries— how many times to retry idempotent requests after a transport failure. Defaults to1.:max_auth_renewals— how many times a single request will renew its token and retry after a401. Defaults to2; more than one matters only when a burst of requests is wide enough for the freshly minted token to expire before every one of them has used it.:answer_count_limit— a default cap on answers per query, applied unless the query passes its own. Unset by default. The HTTP API is not streaming and TypeDB does not cap results itself, so an unboundedmatchreally does materialise the whole match set on the server and ship it; setting this once per connection is the cheap guard against that.:retry_backoff— either{:exponential, base_ms}or a(attempt -> ms)function. Defaults to{:exponential, 100}.
Reading configuration from the environment
TypeDB.start_link(
url: System.fetch_env!("TYPEDB_URL"),
username: System.fetch_env!("TYPEDB_USERNAME"),
password: System.fetch_env!("TYPEDB_PASSWORD")
)
Summary
Functions
The HTTP API version this driver speaks.
Computes the backoff delay, in milliseconds, before retry attempt (1-based).
The option keys new/1 accepts. Anything else is rejected.
Validates connection options.
Same as new/1 but raises TypeDB.Error on invalid options.
Builds the absolute URL for an unversioned API path, such as /health.
Builds the absolute URL for a versioned API path.
Types
@type t() :: %TypeDB.Config{ answer_count_limit: pos_integer() | nil, base_url: String.t(), connect_timeout: timeout(), http_adapter: module(), http_opts: keyword(), max_auth_renewals: non_neg_integer(), max_retries: non_neg_integer(), name: atom(), password: String.t() | nil, retry_backoff: {:exponential, pos_integer()} | (pos_integer() -> non_neg_integer()), static_token: String.t() | nil, timeout: timeout(), username: String.t() | nil }
Functions
@spec api_version() :: String.t()
The HTTP API version this driver speaks.
@spec backoff(t(), pos_integer()) :: non_neg_integer()
Computes the backoff delay, in milliseconds, before retry attempt (1-based).
@spec known_options() :: [atom()]
The option keys new/1 accepts. Anything else is rejected.
@spec new(keyword()) :: {:ok, t()} | {:error, TypeDB.Error.t()}
Validates connection options.
Returns {:ok, config} or {:error, %TypeDB.Error{kind: :config}}.
Same as new/1 but raises TypeDB.Error on invalid options.
Builds the absolute URL for an unversioned API path, such as /health.
Builds the absolute URL for a versioned API path.
iex> config = TypeDB.Config.new!(url: "http://localhost:8000", token: "t")
iex> TypeDB.Config.url(config, "/databases/social")
"http://localhost:8000/v1/databases/social"