Eai.Hub.Loader (eai v1.0.4)

Copy Markdown

Lists and inspects hook files from config/hooks/.

This module is a read-only introspection helper — it does not compile or register hooks. Use Eai.Hub.reload!/0 for that.

Why separate from Reloader?

Reloader owns the compile + register side-effect path. Loader owns the discovery + inspection path (pure read, no BEAM mutations). Keeping them separate lets us query what would be loaded without triggering a full reload — useful for tooling, debugging, and tests.

Usage

iex> Eai.Hub.Loader.list_files()
["01_example.exs", "02_session_log.exs"]

iex> Eai.Hub.Loader.current_hooks()
[{MyHook, 10}, {SessionLogHook, 20}]

Summary

Functions

Return the currently registered hooks from :persistent_term.

List hook .exs filenames in load order (sorted by filename).

Pretty-print the current hook registry to stdout.

Functions

current_hooks()

@spec current_hooks() :: [{module(), non_neg_integer()}]

Return the currently registered hooks from :persistent_term.

This is what's actually running — may differ from disk files if reload!/0 hasn't been called since a file was added/removed.

list_files()

@spec list_files() :: {:ok, [String.t()]} | {:error, term()}

List hook .exs filenames in load order (sorted by filename).

Returns {:ok, [filename]} or {:error, reason} if the dir is missing.