Where to configure plugin global config_data?

We’re developing a golang plugin, and we’re able to configure any meta-data which is specific to one api-definition by specifying the ‘config_data’ for that api def.

However, we would also like to configure the plugin with some global settings (which is shared by all api definitions), for example a database hostname. The plugin system supports a func called ‘init’, however that function does not take any parameters.

How can we configure the plugin during initialization ?

Kind regards, Barry


The init() function is run once when the plugin is loaded. Because of that it isn’t in the context of an API call so the API specific details are unknown to the plugin. Bear in mind that the same plugin may be called by multiple APIs so the init function needs to take general actions not API specific actions.

init() can be used to initialise any globals that are needed by reading config file, environment variables or calling configuration APIs. The options are but very broad. Whatever you can code in golang you can do there. Here is a complex example (please note that it is completely unsupported and just and example) which reads a config file and configures itself. Another example which sets up a AWS connection details and another which reads from environment variables.