ExMqtt.URI (ex_mqtt_uv v0.1.0)

Copy Markdown View Source

Parses MQTT connection URIs into ExMqtt.start_link/1 keyword options.

Supported Schemes

Examples

iex> ExMqtt.URI.parse("mqtt://broker.local")
{:ok, [transport: ExMqtt.Transport.TCP, host: "broker.local", port: 1883]}

iex> ExMqtt.URI.parse("wss://alice:secret@broker.local:8084/mqtt")
{:ok,
 [
   transport: ExMqtt.Transport.WebSocket,
   tls: true,
   host: "broker.local",
   port: 8084,
   path: "/mqtt",
   username: "alice",
   password: "secret"
 ]}

Summary

Functions

Expands the :uri option inside a keyword list if present. Explicit keyword options take precedence over values parsed from :uri.

Parses an MQTT URI string into connection options.

Same as parse/1, raising ArgumentError on invalid URIs.

Functions

expand_opts(opts)

@spec expand_opts(keyword()) :: keyword()

Expands the :uri option inside a keyword list if present. Explicit keyword options take precedence over values parsed from :uri.

parse(uri_string)

@spec parse(String.t()) :: {:ok, keyword()} | {:error, term()}

Parses an MQTT URI string into connection options.

parse!(uri_string)

@spec parse!(String.t()) :: keyword()

Same as parse/1, raising ArgumentError on invalid URIs.