Lotus.Source.Resolver behaviour (Lotus v1.0.0)

Copy Markdown View Source

Behaviour for resolving named data sources to adapters.

This is a supported extension point. The default implementation (Lotus.Source.Resolvers.Static) reads from static data_sources configuration, which is all most applications need. Alternative implementations can resolve sources from registries, databases, or external services — for example to register sources at runtime, to manage per-tenant sources, or to change the set of available sources without restarting the application.

Configure a custom resolver via the :source_resolver config key:

config :lotus,
  source_resolver: MyApp.SourceResolver

See the Custom Resolvers guide for contracts, minimal examples, and testing guidance.

Summary

Callbacks

default_source()

@callback default_source() :: {String.t(), Lotus.Source.Adapter.t()}

get_source!(name)

@callback get_source!(name :: String.t()) :: Lotus.Source.Adapter.t() | no_return()

list_source_names()

@callback list_source_names() :: [String.t()]

list_sources()

@callback list_sources() :: [Lotus.Source.Adapter.t()]

resolve(source_opt, fallback)

@callback resolve(
  source_opt :: nil | String.t() | module(),
  fallback :: nil | String.t() | module()
) :: {:ok, Lotus.Source.Adapter.t()} | {:error, term()}