Lotus.Source.Resolvers.Static (Lotus v1.0.0)

Copy Markdown View Source

Default source resolver that reads from static data_sources configuration.

Resolution priority:

  1. source_opt as string name — lookup in data_sources, wrap in adapter
  2. source_opt as module — reverse lookup (find name for module), wrap in adapter
  3. fallback as string name — lookup
  4. fallback as module — reverse lookup
  5. Both nil — use Config.default_data_source()
  6. Not found — {:error, :not_found}

Entry forms

A :data_sources entry is one of:

  • an Ecto.Repo module — matched against the built-in Ecto adapters by the repo's Ecto adapter, falling back to the generic Ecto adapter.

  • %{adapter: MyAdapter, ...} — the canonical form. The named module is used directly; the whole map is passed to its wrap/2 as state. Prefer this: it is explicit, skips can_handle?/1 probing, and cannot become ambiguous.

  • any other term — offered to each module in :source_adapters via can_handle?/1. Exactly one must claim it. If several do, resolution raises rather than silently picking the first; name the adapter in the entry to settle it.