PluginManager

BaseManagerProcessScope

class trinity.extensibility.plugin_manager.BaseManagerProcessScope

Define the operational model under which a PluginManager works. Subclasses define whether a PluginManager is responsible to manage a specific plugin and how its PluginContext is created.

create_plugin_context(plugin: trinity.extensibility.plugin.BasePlugin, boot_info: trinity.extensibility.plugin.TrinityBootInfo) → None

Create the PluginContext for the given plugin.

is_responsible_for_plugin(plugin: trinity.extensibility.plugin.BasePlugin) → bool

Define whether a PluginManager operating under this scope is responsible to manage the given plugin.

MainAndIsolatedProcessScope

class trinity.extensibility.plugin_manager.MainAndIsolatedProcessScope(main_proc_endpoint: trinity.endpoint.TrinityMainEventBusEndpoint)
create_plugin_context(plugin: trinity.extensibility.plugin.BasePlugin, boot_info: trinity.extensibility.plugin.TrinityBootInfo) → None

Create a PluginContext that creates a new Endpoint dedicated to the isolated plugin that runs in its own process. The Endpoint enable application wide event-driven communication even across process boundaries.

is_responsible_for_plugin(plugin: trinity.extensibility.plugin.BasePlugin) → bool

Return True if if the plugin instance is a subclass of BaseIsolatedPlugin or BaseMainProcessPlugin

SharedProcessScope

class trinity.extensibility.plugin_manager.SharedProcessScope(shared_proc_endpoint: trinity.endpoint.TrinityEventBusEndpoint)
create_plugin_context(plugin: trinity.extensibility.plugin.BasePlugin, boot_info: trinity.extensibility.plugin.TrinityBootInfo) → None

Create a PluginContext that uses the Endpoint of the PluginManager as the event bus that enables application wide, event-driven communication even across process boundaries.

is_responsible_for_plugin(plugin: trinity.extensibility.plugin.BasePlugin) → bool

Return True if if the plugin instance is a subclass of BaseAsyncStopPlugin.

PluginManager

class trinity.extensibility.plugin_manager.PluginManager(scope: trinity.extensibility.plugin_manager.BaseManagerProcessScope)

The plugin manager is responsible to register, keep and manage the life cycle of any available plugins.

A PluginManager is tight to a specific BaseManagerProcessScope which defines which plugins are controlled by this specific manager instance.

This is due to the fact that Trinity currently allows plugins to either run in a shared process, also known as the “networking” process, as well as in their own isolated processes.

Trinity uses two different PluginManager instances to govern these different categories of plugins.

Note

This API is very much in flux and is expected to change heavily.

amend_argparser_config(arg_parser: argparse.ArgumentParser, subparser: argparse._SubParsersAction) → None

Call configure_parser() for every registered plugin, giving them the option to amend the global parser setup.

event_bus_endpoint

Return the Endpoint that the PluginManager instance uses to connect to the event bus.

prepare(args: argparse.Namespace, trinity_config: trinity.config.TrinityConfig, boot_kwargs: Dict[str, Any] = None) → None

Create and set the PluginContext and call ready() on every plugin that this plugin manager instance is responsible for.

register(plugins: Union[trinity.extensibility.plugin.BasePlugin, Iterable[trinity.extensibility.plugin.BasePlugin]]) → None

Register one or multiple instances of BasePlugin with the plugin manager.

coroutine shutdown() → None

Asynchronously shut down all running plugins. Raises an UnsuitableShutdownError if called on a PluginManager that operates in the MainAndIsolatedProcessScope.

shutdown_blocking() → None

Synchronously shut down all running plugins. Raises an UnsuitableShutdownError if called on a PluginManager that operates in the SharedProcessScope.