Adapter wrapping any Ecto.Repo module in the Lotus.Source.Adapter behaviour.
Delegates database-specific operations to dialect modules under
Lotus.Source.Adapters.Ecto.Dialects.* based on the repo's underlying
Ecto adapter.
Usage
adapter = Lotus.Source.Adapters.Ecto.wrap("main", MyApp.Repo)
Lotus.Source.Adapter.execute_query(adapter, "SELECT 1", [], [])
Lotus.Source.Adapter.list_schemas(adapter)The state field of the resulting %Adapter{} struct holds the repo module
itself, since Ecto repos are statically supervised and don't require explicit
connection management.
Extending with custom Ecto-backed adapters
External libraries can create Ecto-backed adapters by writing a dialect module and a one-liner adapter:
defmodule LotusMSSql.Adapter do
use Lotus.Source.Adapters.Ecto, dialect: LotusMSSql.Dialect
endThe use macro injects default implementations for all
Lotus.Source.Adapter callbacks, delegating shared Ecto logic to helper
functions in this module and dialect-specific callbacks to the provided
:dialect module. All callbacks are defoverridable.
Summary
Functions
Returns the list of built-in per-dialect Ecto adapter modules.
Used by Lotus.Source.Resolvers.Static to avoid duplicating this list.
Whether this adapter can handle the given data source entry.
Returns true for any module that exports __adapter__/0. This is
intentionally broad — it acts as a catch-all fallback for Ecto repos
that don't match a more specific per-dialect adapter. The resolver
checks per-dialect adapters first (via builtin_adapters/0 and
source_adapters config), so this only matches repos with unknown
Ecto adapters.
@spec detect_source_type(module()) :: Lotus.Source.Adapter.source_type()
Detects the source type from a repo module's underlying Ecto adapter.
Examples
iex> Lotus.Source.Adapters.Ecto.detect_source_type(MyApp.Repo)
:postgres
@spec wrap(String.t(), module()) :: Lotus.Source.Adapter.t()
Wraps an Ecto.Repo module in an %Adapter{} struct.
The resulting adapter delegates all callbacks to the appropriate source implementation based on the repo's underlying Ecto adapter.
Parameters
name— a human-readable identifier (e.g."main","warehouse")repo_module— the Ecto.Repo module (e.g.MyApp.Repo)
Examples
iex> adapter = Lotus.Source.Adapters.Ecto.wrap("main", MyApp.Repo)
%Lotus.Source.Adapter{name: "main", module: Lotus.Source.Adapters.Ecto, ...}