Mosaic Plugins are lifecycle-based hooks that are called on every source at different stages. You will never need to invoke a lifecycle method directly as their execution is managed by a plugin runner.
Plugins enable Mosaic to have a lightweight and flexible, modular architecture by encapsulating features and functionality as plugins.
yarn add @jpmorganchase/mosaic-plugins
Plugins are added to the plugins
collection of the mosaic config file. Like sources, plugins have an options property that can be used to provide plugin specific configuration.
Property | Description | Required |
---|---|---|
modulePath | The path to the installed plugin module | Yes |
disabled | Exclude this plugin completely. Defaults to false | No |
runtimeOnly | Exclude this plugin when generating a snapshot. Defaults to false | No |
previewDisabled | Exclude this plugin for "preview" sources | No |
allowMultiple | Allow multiple instances of this plugin to run. | No |
priority | The importance of this plugin. Plugins with the highest priority run first | No |
options | Collection of other configuration values | No |
There is no need to import the plugin module directly. As long as the plugin is installed, Mosaic will be able to import it using the built-in plugin loader.
The following plugins are always included by Mosaic, regardless of whether they are present in the plugins collection of the Mosaic config file:
Should a plugin fail, the failure will not cause a source to close or for any other plugin to not run.
Instead plugin errors are tracked by Mosaic and can be viewed in the pluginErrors
property available on each source listed by the list sources admin API.
Plugin errors will be split by lifecycle event and only the lifecycle events used by the loaded plugins used will be shown.
By default, Mosaic will only run one instance of a plugin.
It may be the case that you wish to run the same plugin twice with a slightly different config. To do this, you must have 2 instances listed in the plugins collection and they both must set the allowMultiple
option to true
.
For example, the config below runs the SidebarPlugin twice: