vdev Knot.Via

Helps building Registry based process names.

Link to this section Summary

Functions

Builds a via-tuple for a node clients supervisor given an URI

Builds a via-tuple for a node connectors supervisor given an URI

Generates a per-uri unique ID that is suitable for via-tuple generation

Builds a via-tuple for a node listener given an URI

Builds a via-tuple for a node logic given an URI

Given an URI and a suffix, returns a via-tuple compatible with Registry

Builds a via-tuple for a node given an URI

Transforms a URI into a displayable string

Link to this section Types

Link to this type id()
id() :: {String.t, pos_integer, service_type}
Link to this type service_type()
service_type() :: :node | :clients | :connectors | :logic | :listener
Link to this type t()
t() :: {:via, Registry, {Knot.Registry, Knot.Via.id}}
Link to this type uri_or_address()
uri_or_address() :: URI.t | String.t

Link to this section Functions

Link to this function clients(uri_or_address)

Builds a via-tuple for a node clients supervisor given an URI.

Examples

iex> Knot.Via.clients "tcp://localhost:4001"
{:via, Registry, {Knot.Registry, {"localhost", 4001, :clients}}}
Link to this function connectors(uri_or_address)

Builds a via-tuple for a node connectors supervisor given an URI.

Examples

iex> Knot.Via.connectors "tcp://localhost:4001"
{:via, Registry, {Knot.Registry, {"localhost", 4001, :connectors}}}
Link to this function id(uri_or_address, suffix)

Generates a per-uri unique ID that is suitable for via-tuple generation.

Examples

iex> Knot.Via.id "tcp://localhost:4001", :whatever
{"localhost", 4001, :whatever}

iex> "tcp://localhost:4001" |> URI.parse |> Knot.Via.id(:whatever)
{"localhost", 4001, :whatever}
Link to this function listener(uri_or_address)

Builds a via-tuple for a node listener given an URI.

Examples

iex> Knot.Via.listener "tcp://localhost:4001"
{:via, Registry, {Knot.Registry, {"localhost", 4001, :listener}}}
Link to this function logic(uri_or_address)

Builds a via-tuple for a node logic given an URI.

Examples

iex> Knot.Via.logic "tcp://localhost:4001"
{:via, Registry, {Knot.Registry, {"localhost", 4001, :logic}}}
Link to this function make(uri_or_address, suffix)

Given an URI and a suffix, returns a via-tuple compatible with Registry.

Examples

iex> Knot.Via.make "tcp://localhost:4001", :whatever
{:via, Registry, {Knot.Registry, {"localhost", 4001, :whatever}}}

iex> "tcp://localhost:4001" |> URI.parse |> Knot.Via.make(:whatever)
{:via, Registry, {Knot.Registry, {"localhost", 4001, :whatever}}}
Link to this function node(uri_or_address)

Builds a via-tuple for a node given an URI.

Examples

iex> Knot.Via.node "tcp://localhost:4001"
{:via, Registry, {Knot.Registry, {"localhost", 4001, :node}}}
Link to this function registry()
registry() :: Knot.Registry
Link to this function to_string(uri_or_address)
to_string(uri_or_address) :: String.t

Transforms a URI into a displayable string.

Examples

iex> Knot.Via.to_string "tcp://localhost:4001"
"localhost:4001"

iex> "tcp://localhost:4001" |> URI.parse |> Knot.Via.to_string
"localhost:4001"