PluginManager¶
BaseManagerProcessScope¶
-
class
trinity.extensibility.plugin_manager.BaseManagerProcessScope¶ Define the operational model under which a
PluginManagerworks. Subclasses define whether aPluginManageris responsible to manage a specific plugin and how itsPluginContextis created.-
create_plugin_context(plugin: trinity.extensibility.plugin.BasePlugin, boot_info: trinity.extensibility.plugin.TrinityBootInfo) → None¶ Create the
PluginContextfor the givenplugin.
-
is_responsible_for_plugin(plugin: trinity.extensibility.plugin.BasePlugin) → bool¶ Define whether a
PluginManageroperating under this scope is responsible to manage the givenplugin.
-
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
PluginContextthat creates a newEndpointdedicated to the isolated plugin that runs in its own process. TheEndpointenable application wide event-driven communication even across process boundaries.
-
is_responsible_for_plugin(plugin: trinity.extensibility.plugin.BasePlugin) → bool¶ Return
Trueif if the plugin instance is a subclass ofBaseIsolatedPluginorBaseMainProcessPlugin
-
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
PluginManageris tight to a specificBaseManagerProcessScopewhich 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
PluginManagerinstances 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
Endpointthat thePluginManagerinstance 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
PluginContextand callready()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
BasePluginwith the plugin manager.
-
coroutine
shutdown() → None¶ Asynchronously shut down all running plugins. Raises an
UnsuitableShutdownErrorif called on aPluginManagerthat operates in theMainAndIsolatedProcessScope.
-
shutdown_blocking() → None¶ Synchronously shut down all running plugins. Raises an
UnsuitableShutdownErrorif called on aPluginManagerthat operates in theSharedProcessScope.
-