# `NebulaAPI.Routes`
[🔗](https://github.com/podCloud/nebula_api/blob/v0.7.1/lib/nebula_api/routes.ex#L1)

The per-node routing map — where each `defapi` is served locally vs reached over RPC.

Built entirely from compile-time data (`:nebula_configured_nodes`, the single source of truth
also behind `NebulaAPI.APIServer.configured_nodes/2`): a method is *local* on the nodes in its
configured serving set. Nothing is recomputed; no cluster needed.

Rendered "git lola"-style — one continuous vertical rail per node, with a `●` marking each node
that serves a method; the rail simply continues (`|`) where it isn't local. The static view
asserts only locality (config-known) — it does **not** claim a method actually runs elsewhere;
pass `available: true` for the live picture (`∆`/`x`/`X` from `:pg` + `Node.list`). Printed by
`mix nebula.routes` and `NebulaAPI.Server.print_routes/0`.

## Scope

It lists only the modules — and their `defapi` — **present in this build** (the one compiled for
`compiled_node()`). A node whose release carries a subset of an umbrella's apps does not carry
the other apps' modules, so those modules and their methods are simply absent from the map;
modules not imported/used by this build are not shown either. Run it from a node/release that
carries every app for the full picture.

# `build`

The routing rows for the given modules and topology.

`module_methods` is `[{module, [{{fun, arity}, configured_nodes}, ...]}, ...]`; `node_names`
the topology's node names. Returns one row per method (sorted by module), shaped:

    %{module: M, fun: f, arity: a, nodes: %{node => :local | :remote}}

# `build_available`

Overlay live cluster state onto static rows (the `--available` view). Per serving node, the
static `:local` becomes — relative to `current_node` and the runtime facts — `:local` (this
node), `:remote_available` (connected + a live worker), `:worker_unavailable` (connected, no
worker), or `:node_unavailable` (disconnected). A `:remote` cell (the node doesn't serve the
method) becomes `:not_served`.

When `current_node` is not in `connected` we can't observe the cluster at all (e.g. the task
runs as `nonode@nohost` and `current_node` is only the config `self_node` fallback): every cell
becomes `:unknown` rather than asserting a (false) `:node_unavailable`.

`connected` is the list of reachable node names; `available_by_method` maps
`{module, {fun, arity}}` to the nodes with a live worker (from `NebulaAPI.APIServer.available_nodes/2`).

# `discover`

`[{module, [{{fun, arity}, configured_nodes}, ...]}]` for every loaded module that persisted a
NebulaAPI configured set (i.e. has `defapi` endpoints).

# `print`

Discover, build, sort, and print the routing map for the current node.

Options:
  * `:available` — overlay live `:pg` + `Node.list` state (`∆`/`x`/`X`; `|` when this node
    can't observe the cluster). Default `false`.
  * `:follow` — refresh every 5s (implies `:available`). Default `false`.
  * `:sort` — `:module` (default), `:name`, or `:locality` (most-local-first).
  * `:color` — ANSI color (default `true`).
  * `:nodes` (`[{name, tags}]`), `:current_node`, `:modules` — override the discovered
    topology / current node / module set (mainly for tests).

# `render`

Render the routing map as a "git lola"-style graph string.

`nodes` is the topology as `[{name, tags}]` (the `config :nebula_api, :nodes` shape). Each node
gets a continuous vertical rail, introduced top-down with its name and selectors (`@short &tag …`);
then one row per method: `●` where the method is local, the rail (`|`) where it isn't. The
`current_node`'s rail label is bold. With `available: true` the per-cell glyphs reflect live
state (`∆`/`x`/`X`, `|` when this node can't observe the cluster). Options: `:color` (default
true), `:available`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
