Marvin Live developer guide - storage plugins¶
Marvin Live storage plugins automatically save snapshots to databases added in version 16.9.26. These plugins are NodeJS modules, stored in a folder set by Marvin Live's configuration file.
Prerequisites¶
- an instance of Marvin Live available for development purposes, i.e.: the ability to stop and start it, to try different configuration options
- familiarity with JavaScript, NodeJS and its module system
NodeJS introduction material: https://www.youtube.com/watch?v=_l96hPlqzcI (78m), https://www.youtube.com/watch?v=hKQr2DGJjUQ (19m), https://www.youtube.com/watch?v=cJVXP1bU68Y (48m)
NodeJS module description: http://nodejs.org/api/modules.html
Storage plugins¶
This plugin type is intended to save important information from a discussion room, to a shared idea database.
Life-cycle¶
Marvin Live scans the services directory to find all storage plugins and loads them on start. There is 1 instance of a plugin per room.
Specification¶
Export plugins are NodeJS modules , denoted by their filename: *.storage.jsand the location in the services directory as configured during installation.
An export plugin exports the following required properties:
| Name | Type | Description |
|---|---|---|
| name | string | Unique identifier of the plugin, used by Marvin Live for identification and internal communication. If multiple plugins use the same identifier, the last one to be loaded overrides the others. |
| insertSnapshot | function | The main function of the plugin, called when chemists save a snapshot, once for each snapshot. The function should have a void return type.Arguments: * snapshot (Object) data structure containing chemical structure and metadata. See specification below. * thisincludes domain, roomName and URL for this roomRequired: yes |
| updateSnapshot | function | Called when chemists change the metadata of a snapshot, once for each change. The function should have a void return type.Arguments: * snapshot (Object) data structure containing structures and comments. See specification below. * thisincludes domain, roomName and URL for this roomRequired: no |
| domains | array of strings | List of domains where this plugin may be used, when authentication is enabled in Marvin Live. Use * to allow any domain. If no authentication is setup, this option has no effect. To query the configured domains, send a GETrequest to /domains or open /domains in your browser. |
| enablePrivateDataStorage | boolean | Configures the application to enable this plugin in rooms that are set to private. Private rooms are visible only to their owner and those invited.Required: noDefault: false |
Snapshot data specification¶
Below is an example of a snapshot object, with inline description of the individual attributes.
Examples¶
You can find a brief selection of plugins in our Github repository for: Oracle, JChem Oracle Cartridge, Postgres, JChem Postgres Cartridge and MySQL.
