diff --git a/plugins/cli/cli.go b/plugins/cli/cli.go index bd362093255aa46f242c20b562551fdb983aa4d3..740d23b13c96990f68186bbf4bc5fd919411c6e6 100644 --- a/plugins/cli/cli.go +++ b/plugins/cli/cli.go @@ -14,6 +14,7 @@ import ( var enabledPlugins []string var disabledPlugins []string +// AddPluginStatus adds the status (enabled=1, disabled=0) of a given plugin. func AddPluginStatus(name string, status int) { switch status { case node.Enabled: diff --git a/plugins/config/plugin.go b/plugins/config/plugin.go index f9353574a50a34f23459a189cfa4f4d8e3fc3842..596ad2b58633bc3a1b612a13b15810b77bf9bb78 100644 --- a/plugins/config/plugin.go +++ b/plugins/config/plugin.go @@ -5,9 +5,8 @@ import ( "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" - "github.com/spf13/viper" - flag "github.com/spf13/pflag" + "github.com/spf13/viper" ) // PluginName is the name of the config plugin. @@ -21,7 +20,7 @@ var ( configName = flag.StringP("config", "c", "config", "Filename of the config file without the file extension") configDirPath = flag.StringP("config-dir", "d", ".", "Path to the directory containing the config file") - // viper + // Node is viper Node *viper.Viper // logger @@ -35,6 +34,7 @@ var ( } ) +// Init triggers the Init event. func Init() { Plugin.Events.Init.Trigger(Plugin) } diff --git a/plugins/database/plugin.go b/plugins/database/plugin.go index 2227b4ffc8cfc015dabbf9749c3246fa81900b1c..6a006b7bc0798daab622f890f60e8fc6596366a2 100644 --- a/plugins/database/plugin.go +++ b/plugins/database/plugin.go @@ -1,17 +1,15 @@ -// database is a plugin that manages the badger database (e.g. garbage collection). +// Package database is a plugin that manages the badger database (e.g. garbage collection). package database import ( "time" - "github.com/iotaledger/hive.go/timeutil" - "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/goshimmer/packages/shutdown" - "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/timeutil" ) // PluginName is the name of the database plugin. diff --git a/plugins/logger/plugin.go b/plugins/logger/plugin.go index 9381eef4cabab9647439b05a2500f259832b5b90..5ccfc62be80457fbdba956775f7a9d1d1e20467c 100644 --- a/plugins/logger/plugin.go +++ b/plugins/logger/plugin.go @@ -13,6 +13,7 @@ const PluginName = "Logger" // Plugin is the plugin instance of the logger plugin. var Plugin = node.NewPlugin(PluginName, node.Enabled) +// Init triggers the Init event. func Init() { Plugin.Events.Init.Trigger(Plugin) } diff --git a/plugins/messagelayer/plugin.go b/plugins/messagelayer/plugin.go index e2729184438f0485be6af63818e0059e397d6931..3aaed4c30318351bc48bd1872dea6cc0477f912f 100644 --- a/plugins/messagelayer/plugin.go +++ b/plugins/messagelayer/plugin.go @@ -1,13 +1,6 @@ package messagelayer import ( - "github.com/iotaledger/hive.go/autopeering/peer" - - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/goshimmer/packages/binary/messagelayer/message" "github.com/iotaledger/goshimmer/packages/binary/messagelayer/messagefactory" "github.com/iotaledger/goshimmer/packages/binary/messagelayer/messageparser" @@ -17,6 +10,11 @@ import ( "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/hive.go/autopeering/peer" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" ) const ( diff --git a/plugins/metrics/events.go b/plugins/metrics/events.go index 7f7721bf0a3ac575230f1decd686d44bf5924827..acdb127c0496520a502e235fd9a7eaa7627122c8 100644 --- a/plugins/metrics/events.go +++ b/plugins/metrics/events.go @@ -4,7 +4,9 @@ import ( "github.com/iotaledger/hive.go/events" ) +// Events defines the events of the plugin. var Events = pluginEvents{ + // ReceivedMPSUpdated triggers upon reception of a MPS update. ReceivedMPSUpdated: events.NewEvent(uint64EventCaller), } diff --git a/plugins/profiling/plugin.go b/plugins/profiling/plugin.go index 6e82365051ee49d18b9efccae5957c56bbf54578..0a4cb782d62536b2c979673ee3ea9b88d04582ab 100644 --- a/plugins/profiling/plugin.go +++ b/plugins/profiling/plugin.go @@ -2,6 +2,7 @@ package profiling import ( "net/http" + // import required to profile _ "net/http/pprof" "github.com/iotaledger/goshimmer/plugins/config" @@ -10,9 +11,11 @@ import ( ) var ( + // Plugin is the profiling plugin. Plugin = node.NewPlugin("Profiling", node.Enabled, configure, run) ) +// CfgProfilingBindAddress defines the config flag of the profiling binding address. const CfgProfilingBindAddress = "profiling.bindAddress" func init() { diff --git a/plugins/remotelog/plugin.go b/plugins/remotelog/plugin.go index f69fe1b93afe85dc335b7585778d542fd2b1f488..32f6ad6bcf5e857d7ff8fba894ea697f9a5ee55b 100644 --- a/plugins/remotelog/plugin.go +++ b/plugins/remotelog/plugin.go @@ -1,4 +1,4 @@ -// remotelog is a plugin that enables log messages being sent via UDP to a central ELK stack for debugging. +// Package remotelog is a plugin that enables log messages being sent via UDP to a central ELK stack for debugging. // It is disabled by default and when enabled, additionally, logger.disableEvents=false in config.json needs to be set. // The destination can be set via logger.remotelog.serverAddress. // All events according to logger.level in config.json are sent. @@ -18,13 +18,11 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/banner" "github.com/iotaledger/goshimmer/plugins/config" - "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/workerpool" - "gopkg.in/src-d/go-git.v4" ) @@ -32,7 +30,7 @@ type logMessage struct { Version string `json:"version"` GitHead string `json:"gitHead,omitempty"` GitBranch string `json:"gitBranch,omitempty"` - NodeId string `json:"nodeId"` + NodeID string `json:"nodeId"` Level string `json:"level"` Name string `json:"name"` Msg string `json:"msg"` @@ -40,7 +38,9 @@ type logMessage struct { } const ( + // CfgServerAddress defines the config flag of the server address. CfgServerAddress = "logger.remotelog.serverAddress" + // CfgDisableEvents defines the config flag for disabling logger events. CfgDisableEvents = "logger.disableEvents" // PluginName is the name of the remote log plugin. PluginName = "RemoteLog"