FireMQ.URL (firemq v0.1.0)

Copy Markdown View Source

Parses connection URLs.

fire://user:password@host:5673/vhost

The schemes are fire (TCP, port 5673), fires (TLS, port 5674), ws (port 15672) and wss (port 15671). User and password default to guest. For fire and fires the vhost is the path without its leading /, percent-decoded; an empty path means vhost /. For ws and wss the path is the WebSocket endpoint (/fire when empty) and the vhost is the vhost query parameter.

This client connects over fire and fires. WebSocket URLs parse, but FireMQ.connect/2 rejects them.

Summary

Functions

Parses a URL and fills in the defaults.

Types

t()

@type t() :: %FireMQ.URL{
  host: String.t(),
  pass: String.t(),
  path: String.t(),
  port: :inet.port_number(),
  transport: transport(),
  user: String.t(),
  vhost: String.t()
}

transport()

@type transport() :: :tcp | :tls | :ws | :wss

Functions

parse(input)

@spec parse(String.t()) :: {:ok, t()} | {:error, FireMQ.Error.t()}

Parses a URL and fills in the defaults.

iex> {:ok, url} = FireMQ.URL.parse("fire://localhost")
iex> {url.transport, url.port, url.vhost, url.user}
{:tcp, 5673, "/", "guest"}