Metastatic.Supplemental.Registry
(Metastatic v0.10.4)
View Source
Registry for supplemental modules.
Manages registration and lookup of supplemental modules that extend language adapter capabilities. Runs as a GenServer under the application supervision tree.
Usage
# Register a supplemental module
Registry.register(MyApp.Supplemental.Python.Pykka)
# Look up by language
Registry.list_for_language(:python)
# Look up by construct
Registry.get_for_construct(:python, :actor_call)
# List all available constructs for a language
Registry.available_constructs(:python)Configuration
Auto-register supplementals at application startup:
# config/config.exs
config :metastatic, :supplementals,
auto_register: [Metastatic.Supplemental.Python.Pykka],
disabled: [:some_supplemental]
Summary
Functions
Lists all constructs that have supplemental support for a language.
Returns a specification to start this module under a supervisor.
Clears all registered supplementals.
Gets the supplemental module that handles a specific construct for a language.
Lists all registered supplemental modules.
Lists all supplemental modules registered for a language.
Registers a supplemental module.
Starts the registry GenServer.
Unregisters a supplemental module.
Types
Functions
Lists all constructs that have supplemental support for a language.
Examples
iex> Registry.available_constructs(:python)
[:actor_call, :actor_cast, :spawn_actor]
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec clear() :: :ok
Clears all registered supplementals.
Primarily for testing purposes.
Gets the supplemental module that handles a specific construct for a language.
Returns nil if no supplemental is registered.
Examples
iex> Registry.get_for_construct(:python, :actor_call)
MyApp.Supplemental.Python.Pykka
iex> Registry.get_for_construct(:python, :unsupported_construct)
nil
@spec list_all() :: [module()]
Lists all registered supplemental modules.
Examples
iex> Registry.list_all()
[MyApp.Supplemental.Python.Pykka]
Lists all supplemental modules registered for a language.
Examples
iex> Registry.list_for_language(:python)
[MyApp.Supplemental.Python.Pykka, MyApp.Supplemental.Python.Asyncio]
@spec register(module()) :: :ok | {:error, Exception.t()}
Registers a supplemental module.
The module must implement the Metastatic.Supplemental behaviour.
Validates that no conflicts exist (another supplemental already handles
the same constructs for the same language).
Examples
iex> Registry.register(MyApp.Supplemental.Python.Pykka)
:ok
iex> Registry.register(ConflictingModule)
{:error, %ConflictError{}}
@spec start_link(keyword()) :: GenServer.on_start()
Starts the registry GenServer.
Called automatically by the application supervision tree.
@spec unregister(module()) :: :ok
Unregisters a supplemental module.
Removes the module from the registry.
Examples
iex> Registry.unregister(MyApp.Supplemental.Python.Pykka)
:ok