View Source Wayfarer.Utils (wayfarer v0.6.1)
A grab-bag of useful functions which are used all over the codebase.
Summary
Types
@type address_input() :: IP.Address.t() | String.t() | :inet.ip_address()
@type port_number() :: 1..65535
@type scheme() :: :http | :https | :ws | :wss
@type transport() :: :http1 | :http2 | :auto
Functions
@spec sanitise_ip_address(address_input()) :: {:ok, :inet.ip_address()} | {:error, any()}
Verify an IP address and convert it into a tuple.
@spec sanitise_port(port_number()) :: {:ok, port_number()} | {:error, any()}
Verify a port number.
Verify a scheme.
@spec target_to_ms({scheme(), :inet.ip_address(), port_number(), transport()}) :: {{scheme(), {:inet.ip_address()}, port_number(), transport()}}
Convert a target tuple into a tuple safe for injection into a match spec.
@spec targets_to_ms_guard(atom(), [ {scheme(), :inet.ip_address(), port_number(), transport()} ]) :: [ {atom(), any(), any()} ]
Convert a list of targets into a match spec guard.
@spec to_uri(scheme(), address_input(), port_number()) :: {:ok, URI.t()} | {:error, any()}
Convert a scheme, address, port tuple into a URI
.