MySQL Shell 8.0  /  ...  /  Creating Plugin Groups

10.3.2 Creating Plugin Groups

You can create a plugin group by placing the folders for multiple MySQL Shell plugins in a containing folder under the plugins folder. A plugin group can contain a mix of plugins defined using JavaScript and plugins defined using Python. Plugin groups can be used to organize plugins that have something in common, for example:

  • Plugins that provide reports on a particular theme.

  • Plugins that reuse the same common code.

  • Plugins that add functions to the same extension object.

If a subdirectory of the plugins folder does not contain an initialization script (an init.js or init.py file), MySQL Shell treats it as a plugin group and searches its subfolders for the initialization scripts for the plugins. The containing folder can contain other files with code that is shared by the plugins in the plugin group. As for a plugin's subfolder, the containing folder is ignored if its name begins with a dot (.) but otherwise the name is not important to MySQL Shell.

For example, a plugin group comprising all the functions provided by the user-defined MySQL Shell global object ext can be structured like this:

  • The folder C:\Users\exampleuser\AppData\Roaming\MySQL\mysqlsh\plugins\ext is the containing folder for the plugin group.

  • Common code for the plugins is stored in this folder at C:\Users\exampleuser\AppData\Roaming\MySQL\mysqlsh\plugins\ext\common.py

  • The plugins in the plugin group are stored in subfolders of the ext folder, each with an init.py file, for example C:\Users\exampleuser\AppData\Roaming\MySQL\mysqlsh\plugins\ext\helloWorld\init.py.

  • The plugins import the common code from ext.common and use its functions.