Registry for managing plugins and their dependencies.

Maintains the dependency graph and provides plugins in initialization order.

const registry = new PluginRegistry();

registry.register(loggerPlugin);
registry.register(databasePlugin);
registry.register(apiPlugin);

const plugins = registry.getPluginsInOrder();
// Plugins in dependency order

Accessors

Constructors

Methods

  • Registers a plugin.

    Parameters

    • plugin: Plugin

      The plugin to register

    Returns void

    If a plugin with the same name is already registered

    registry.register(new DatabasePlugin());
    
  • Gets a plugin by name.

    Parameters

    • name: string

      The plugin name

    Returns undefined | Plugin

    The plugin if found, undefined otherwise

    const plugin = registry.get('database');
    
  • Gets plugins in topological order (dependency order).

    Plugins are returned in the order they should be initialized.

    Returns Plugin[]

    Array of plugins in dependency order

    If circular dependencies exist

    If a dependency is not found

    const plugins = registry.getPluginsInOrder();
    for (const plugin of plugins) {
    await plugin.initialize(context);
    }
  • Gets plugins in reverse topological order.

    Useful for shutdown (shutdown in reverse initialization order).

    Returns Plugin[]

    Array of plugins in reverse dependency order