Validated connection settings for a LiveKit deployment.
A config holds the server URL and the API credentials used to sign tokens. It performs no I/O and reads no environment variables: the application using the SDK is responsible for sourcing credentials and passing them in.
iex> {:ok, config} = LiveKit.Config.new(
...> url: "https://example.livekit.cloud/",
...> api_key: "api-key",
...> api_secret: "api-secret"
...> )
iex> config.url
"https://example.livekit.cloud"ws:// and wss:// URLs are accepted and normalized to their HTTP
equivalents, since LiveKit deployments are commonly configured with the
signalling URL.
Summary
Functions
The default receive timeout, in milliseconds.
The default connect timeout, in milliseconds.
Builds a validated config.
Same as new/1 but raises LiveKit.Error on invalid options.
Types
@type t() :: %LiveKit.Config{ api_key: String.t(), api_secret: String.t(), receive_timeout: pos_integer(), timeout: pos_integer(), url: String.t() }
Functions
@spec default_receive_timeout() :: pos_integer()
The default receive timeout, in milliseconds.
Examples
iex> LiveKit.Config.default_receive_timeout()
30_000
@spec default_timeout() :: pos_integer()
The default connect timeout, in milliseconds.
Examples
iex> LiveKit.Config.default_timeout()
15_000
@spec new(keyword()) :: {:ok, t()} | {:error, LiveKit.Error.t()}
Builds a validated config.
Options
:url(required) - base URL of the LiveKit deployment.http,https,wsandwssschemes are accepted;ws/wssare rewritten tohttp/https. Trailing slashes are removed.:api_key(required) - LiveKit API key.:api_secret(required) - LiveKit API secret.:timeout- connect timeout in milliseconds. Defaults to15_000.:receive_timeout- response timeout in milliseconds. Defaults to30_000.
Examples
iex> {:ok, config} = LiveKit.Config.new(
...> url: "http://localhost:7880",
...> api_key: "devkey",
...> api_secret: "secret"
...> )
iex> {config.url, config.timeout}
{"http://localhost:7880", 15_000}
iex> {:error, error} = LiveKit.Config.new(url: "ftp://example.com", api_key: "k", api_secret: "s")
iex> error.type
:configuration
Same as new/1 but raises LiveKit.Error on invalid options.
Examples
iex> config = LiveKit.Config.new!(url: "https://example.livekit.cloud", api_key: "k", api_secret: "s")
iex> config.api_key
"k"