Gmqtt uses code generator to generate plugin template.
# run under gmqtt project root directory.
go install ./cmd/gmqctl
$ gmqctl gen plugin --help
code generator
Usage:
gmqctl gen plugin [flags]
Examples:
The following command will generate a code template for the 'awesome' plugin, which makes use of OnBasicAuth and OnSubscribe hook and enables the configuration in ./plugin directory.
gmqctl gen plugin -n awesome -H OnBasicAuth,OnSubscribe -c true -o ./plugin
Flags:
-c, --config Whether the plugin needs a configuration.
-h, --help help for plugin
-H, --hooks string The hooks use by the plugin, multiple hooks are separated by ','
-n, --name string The plugin name.
-o, --output string The output directory.
Append your plugin name to plugin_imports.yml
.
packages:
- admin
- prometheus
- federation
- auth
# for external plugin, use full import path
# - github.com/DrmagicE/gmqtt/plugin/prometheu
Run go generate ./...
under the project root directory. The command will recreate the ./cmd/gmqttd/plugins.go
file,
which is needed during the compile time.