Minga.Extension.Supervisor (Minga v0.1.0)

Copy Markdown View Source

DynamicSupervisor managing extension process trees.

Each extension gets its own child under this supervisor. If an extension crashes, only that extension restarts. The editor and other extensions are unaffected.

Lifecycle

  1. Config eval registers extensions in Extension.Registry
  2. start_all/0 reads the registry and starts each extension
  3. stop_all/0 terminates all running extensions (used by reload)

Summary

Types

Options for extension start/stop that inject collaborator dependencies.

Functions

Returns a specification to start this module under a supervisor.

Returns a summary of all extensions: [{name, version, status}].

Starts all extensions declared in the registry.

Starts the extension supervisor.

Stops all running extensions and purges their modules.

Stops a single extension, terminates its process, and purges the module.

Types

start_opts()

@type start_opts() :: [
  command_registry: GenServer.server(),
  keymap: GenServer.server()
]

Options for extension start/stop that inject collaborator dependencies.

Functions

child_spec(arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list_extensions()

@spec list_extensions() :: [{atom(), String.t(), Minga.Extension.extension_status()}]

Returns a summary of all extensions: [{name, version, status}].

list_extensions(registry)

@spec list_extensions(GenServer.server()) :: [
  {atom(), String.t(), Minga.Extension.extension_status()}
]

start_all()

@spec start_all() :: :ok

Starts all extensions declared in the registry.

Processes extensions in order:

  1. Install all hex extensions via a single Mix.install/2 call
  2. Clone/checkout all git extensions to local cache
  3. Compile and start all extensions (path, git, hex)

Errors at any stage are logged to Messages and stored in the registry as :load_error without affecting other extensions.

start_all(supervisor, registry)

@spec start_all(GenServer.server(), GenServer.server()) :: :ok

start_extension(supervisor, registry, name, entry, opts \\ [])

@spec start_extension(
  GenServer.server(),
  GenServer.server(),
  atom(),
  Minga.Extension.Registry.entry(),
  start_opts()
) :: {:ok, pid()} | {:error, term()}

Starts a single extension by name.

For path extensions, compiles the module from the local directory. Git and hex extensions must be resolved to a local path or loaded via Mix.install before calling this function.

start_link(opts \\ [])

@spec start_link(keyword()) :: Supervisor.on_start()

Starts the extension supervisor.

stop_all()

@spec stop_all() :: :ok

Stops all running extensions and purges their modules.

Used by config reload to cleanly tear down before re-loading.

stop_all(supervisor, registry)

@spec stop_all(GenServer.server(), GenServer.server()) :: :ok

stop_extension(supervisor, registry, name, entry, opts \\ [])

@spec stop_extension(
  GenServer.server(),
  GenServer.server(),
  atom(),
  Minga.Extension.Registry.entry(),
  start_opts()
) :: :ok

Stops a single extension, terminates its process, and purges the module.