Outbox.Registry (Outbox v0.1.0-beta.2)

Copy Markdown View Source

Resolves event names to subscriber modules.

Reads subscribers from Outbox.Config.subscribers/0 on every lookup. No GenServer, no ETS cache — the dispatcher polls every 5 seconds, so the lookup happens at most a few times per second per node; caching would not be a meaningful optimization at this volume.

Trivial-by-design also means tests can override the subscriber list with Application.put_env/3 without restarting the application.

Summary

Functions

Returns the list of subscriber modules listening for the given event name. Returns [] if no subscribers match.

Returns the full list of registered subscriber modules.

Functions

lookup(event_name)

@spec lookup(String.t()) :: [module()]

Returns the list of subscriber modules listening for the given event name. Returns [] if no subscribers match.

A subscriber's events/0 entries may be exact names or patterns:

  • "order.refunded" — exact match
  • "order.*" — prefix wildcard; matches any name under the order. namespace ("order.refunded", "order.line.added"), but not the bare "order" nor an unrelated word like "ordering.created"
  • "*" — matches every event name

A subscriber matched by more than one of its patterns is returned once.

subscribers()

@spec subscribers() :: [module()]

Returns the full list of registered subscriber modules.