Minga.Extension.ContributionCleanup (Minga v0.1.0)

Copy Markdown View Source

Source-owned contribution cleanup coordinator.

The extension supervisor lives in the core Minga.* layer, so it cannot depend on editor presentation modules directly. Editor-layer registries register cleanup callbacks here when they accept source-owned contributions. The supervisor calls this module with a source, and the coordinator cleans core registries plus any registered higher-layer callbacks without creating compile-time upward dependencies.

Summary

Types

Cleanup failure reported for one family.

Cleanup callback invoked with a source identifier.

Cleanup options with injectable test registries.

Source that contributed registry entries.

Functions

Registers a cleanup callback for a contribution family.

Unregisters a cleanup callback. Mostly useful for tests.

Removes all contributions owned by a source.

Types

cleanup_failure()

@type cleanup_failure() :: %{
  family: atom(),
  source: contribution_source(),
  reason: term()
}

Cleanup failure reported for one family.

cleanup_fun()

@type cleanup_fun() :: (contribution_source() -> :ok | {:error, term()})

Cleanup callback invoked with a source identifier.

cleanup_opts()

@type cleanup_opts() :: [
  command_registry: GenServer.server(),
  keymap: GenServer.server(),
  callbacks: %{required(atom()) => cleanup_fun()}
]

Cleanup options with injectable test registries.

contribution_source()

@type contribution_source() ::
  :builtin | :config | {:bundle, atom()} | {:extension, atom()}

Source that contributed registry entries.

Functions

register(name, fun)

@spec register(atom(), cleanup_fun()) :: :ok

Registers a cleanup callback for a contribution family.

unregister(name)

@spec unregister(atom()) :: :ok

Unregisters a cleanup callback. Mostly useful for tests.

unregister_source(source, opts \\ [])

@spec unregister_source(contribution_source(), cleanup_opts()) ::
  :ok | {:error, [cleanup_failure()]}

Removes all contributions owned by a source.