Noizu.Comms.Router (noizu_comms v0.1.0)

Copy Markdown View Source

Alias resolution -> target parse -> adapter dispatch -> policy check -> deliver.

send/3 is synchronous with a single retry on :rate_limited (delay = min(retry_after_ms || 1s, 10s)); the sleep is injectable via app env :noizu_comms, :sleep_fn for tests. broadcast/3 fans out over Task.async_stream and returns one {target, result} entry per target — it never raises.

Emits [:noizu_comms, :send, :start | :stop | :exception] telemetry (:stop carries duration + receipt; :exception carries duration

  • error — note a returned {:error, %Error{}} is an :exception event, not a raise).

Summary

Functions

Sends to many targets concurrently. Returns one {target_argument, {:ok, receipt} | {:error, error}} entry per target, in input order.

Parses a raw target URI or resolves an alias (delegate over Target + Config).

Sends message (map/keyword or %Message{}) to target (alias name, raw URI string, or %Target{}).

Functions

broadcast(targets, message, opts \\ [])

@spec broadcast(
  [String.t() | Noizu.Comms.Target.t()],
  map() | keyword() | Noizu.Comms.Message.t(),
  keyword()
) :: [
  {String.t() | Noizu.Comms.Target.t(),
   {:ok, Noizu.Comms.Receipt.t()} | {:error, Noizu.Comms.Error.t()}}
]

Sends to many targets concurrently. Returns one {target_argument, {:ok, receipt} | {:error, error}} entry per target, in input order.

parse_target(target)

@spec parse_target(String.t() | Noizu.Comms.Target.t()) ::
  {:ok, Noizu.Comms.Target.t()} | {:error, Noizu.Comms.Error.t()}

Parses a raw target URI or resolves an alias (delegate over Target + Config).

send(target, message, opts \\ [])

Sends message (map/keyword or %Message{}) to target (alias name, raw URI string, or %Target{}).

Noizu.Comms.send("ops-alerts", %{text: "deploy done", level: :success})