Skip to content
Snippets Groups Projects
Commit 99a23614 authored by Hans Moog's avatar Hans Moog
Browse files

Feat: adjusted to new hive.go

parent 683d261f
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,7 @@ require ( ...@@ -13,7 +13,7 @@ require (
github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2 github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2
github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0
github.com/gorilla/websocket v1.4.1 github.com/gorilla/websocket v1.4.1
github.com/iotaledger/hive.go v0.0.0-20200222013046-8268a12f52cb github.com/iotaledger/hive.go v0.0.0-20200225022819-32427644698a
github.com/iotaledger/iota.go v1.0.0-beta.14 github.com/iotaledger/iota.go v1.0.0-beta.14
github.com/kr/pretty v0.2.0 // indirect github.com/kr/pretty v0.2.0 // indirect
github.com/kr/text v0.2.0 // indirect github.com/kr/text v0.2.0 // indirect
......
...@@ -141,6 +141,10 @@ github.com/iotaledger/hive.go v0.0.0-20200219224037-2d5f5238c0de h1:J9G9YWM5q7r3 ...@@ -141,6 +141,10 @@ github.com/iotaledger/hive.go v0.0.0-20200219224037-2d5f5238c0de h1:J9G9YWM5q7r3
github.com/iotaledger/hive.go v0.0.0-20200219224037-2d5f5238c0de/go.mod h1:wj3bFHlcX0NiEOWu5+WOg/MI/5N7PKCFnyaziaylB64= github.com/iotaledger/hive.go v0.0.0-20200219224037-2d5f5238c0de/go.mod h1:wj3bFHlcX0NiEOWu5+WOg/MI/5N7PKCFnyaziaylB64=
github.com/iotaledger/hive.go v0.0.0-20200222013046-8268a12f52cb h1:lLObap03uuF0RPSGHflpzIZIdKz2robq/rqT3b1ghqU= github.com/iotaledger/hive.go v0.0.0-20200222013046-8268a12f52cb h1:lLObap03uuF0RPSGHflpzIZIdKz2robq/rqT3b1ghqU=
github.com/iotaledger/hive.go v0.0.0-20200222013046-8268a12f52cb/go.mod h1:wj3bFHlcX0NiEOWu5+WOg/MI/5N7PKCFnyaziaylB64= github.com/iotaledger/hive.go v0.0.0-20200222013046-8268a12f52cb/go.mod h1:wj3bFHlcX0NiEOWu5+WOg/MI/5N7PKCFnyaziaylB64=
github.com/iotaledger/hive.go v0.0.0-20200225021953-8c07d94b7c38 h1:QsBAGr1fPwxrzvvRB2zy27gxDmeBhiWN87LD37jd0ZQ=
github.com/iotaledger/hive.go v0.0.0-20200225021953-8c07d94b7c38/go.mod h1:wj3bFHlcX0NiEOWu5+WOg/MI/5N7PKCFnyaziaylB64=
github.com/iotaledger/hive.go v0.0.0-20200225022819-32427644698a h1:ga4SOHLYzXNCC7qHxBN8lK4kng8Ffu2x2QB+yKolH2w=
github.com/iotaledger/hive.go v0.0.0-20200225022819-32427644698a/go.mod h1:wj3bFHlcX0NiEOWu5+WOg/MI/5N7PKCFnyaziaylB64=
github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8=
github.com/iotaledger/iota.go v1.0.0-beta.14 h1:Oeb28MfBuJEeXcGrLhTCJFtbsnc8y1u7xidsAmiOD5A= github.com/iotaledger/iota.go v1.0.0-beta.14 h1:Oeb28MfBuJEeXcGrLhTCJFtbsnc8y1u7xidsAmiOD5A=
github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8=
......
...@@ -27,7 +27,7 @@ import ( ...@@ -27,7 +27,7 @@ import (
) )
func main() { func main() {
cli.PrintVersion() config.Init()
go http.ListenAndServe("localhost:6061", nil) // pprof Server for Debbuging Mutexes go http.ListenAndServe("localhost:6061", nil) // pprof Server for Debbuging Mutexes
......
...@@ -10,7 +10,7 @@ var PLUGIN = node.NewPlugin("Banner", node.Enabled, configure, run) ...@@ -10,7 +10,7 @@ var PLUGIN = node.NewPlugin("Banner", node.Enabled, configure, run)
const ( const (
// AppVersion version number // AppVersion version number
AppVersion = "v0.1.1" AppVersion = "v0.2.0"
// AppName app code name // AppName app code name
AppName = "GoShimmer" AppName = "GoShimmer"
......
package cli package cli
import ( import (
"fmt"
"os"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
"github.com/iotaledger/goshimmer/plugins/banner"
) )
var PLUGIN = node.NewPlugin("CLI", node.Enabled) var PLUGIN = node.NewPlugin("CLI", node.Enabled)
func onAddPlugin(name string, status int) { var version = flag.BoolP("version", "v", false, "Prints the GoShimmer version")
AddPluginStatus(node.GetPluginIdentifier(name), status)
}
func init() { func init() {
for name, status := range node.GetPlugins() { for name, status := range node.GetPlugins() {
...@@ -20,4 +23,17 @@ func init() { ...@@ -20,4 +23,17 @@ func init() {
node.Events.AddPlugin.Attach(events.NewClosure(onAddPlugin)) node.Events.AddPlugin.Attach(events.NewClosure(onAddPlugin))
flag.Usage = printUsage flag.Usage = printUsage
PLUGIN.Events.Init.Attach(events.NewClosure(onInit))
}
func onAddPlugin(name string, status int) {
AddPluginStatus(node.GetPluginIdentifier(name), status)
}
func onInit(*node.Plugin) {
if *version {
fmt.Println(banner.AppName + " " + banner.AppVersion)
os.Exit(0)
}
} }
package config package config
import ( import (
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"github.com/iotaledger/hive.go/parameter" "github.com/iotaledger/hive.go/parameter"
...@@ -31,8 +32,8 @@ var ( ...@@ -31,8 +32,8 @@ var (
} }
) )
func Load() { func Init() {
// do nothing - the config get's initialized during init() PLUGIN.Events.Init.Trigger(PLUGIN)
} }
func init() { func init() {
...@@ -40,9 +41,11 @@ func init() { ...@@ -40,9 +41,11 @@ func init() {
Node = viper.New() Node = viper.New()
Node.SetDefault(logger.ViperKey, defaultLoggerConfig) Node.SetDefault(logger.ViperKey, defaultLoggerConfig)
if err := fetch(false); err != nil { PLUGIN.Events.Init.Attach(events.NewClosure(func(*node.Plugin) {
panic(err) if err := fetch(false); err != nil {
} panic(err)
}
}))
} }
// fetch fetches config values from a dir defined via CLI flag --config-dir (or the current working dir if not set). // fetch fetches config values from a dir defined via CLI flag --config-dir (or the current working dir if not set).
...@@ -50,6 +53,7 @@ func init() { ...@@ -50,6 +53,7 @@ func init() {
// It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag) // It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag)
// and ending with: .json, .toml, .yaml or .yml (in this sequence). // and ending with: .json, .toml, .yaml or .yml (in this sequence).
func fetch(printConfig bool, ignoreSettingsAtPrint ...[]string) error { func fetch(printConfig bool, ignoreSettingsAtPrint ...[]string) error {
flag.Parse()
err := parameter.LoadConfigFile(Node, *configDirPath, *configName, true, true) err := parameter.LoadConfigFile(Node, *configDirPath, *configName, true, true)
if err != nil { if err != nil {
return err return err
......
package logger package logger
import ( import (
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
"github.com/iotaledger/goshimmer/plugins/config"
) )
// define the plugin as a placeholder, so the init methods get executed accordingly // define the plugin as a placeholder, so the init methods get executed accordingly
var PLUGIN = node.NewPlugin("Logger", node.Enabled) var PLUGIN = node.NewPlugin("Logger", node.Enabled)
func Load() { func Init() {
// do nothing - the config get's initialized during init() PLUGIN.Events.Init.Trigger(PLUGIN)
} }
func init() { func init() {
if err := logger.InitGlobalLogger(config.Node); err != nil { PLUGIN.Events.Init.Attach(events.NewClosure(func(*node.Plugin) {
panic(err) if err := logger.InitGlobalLogger(config.Node); err != nil {
} panic(err)
}
}))
} }
...@@ -40,8 +40,8 @@ func testNodesGetTransactions(txnHash trinary.Hash) error { ...@@ -40,8 +40,8 @@ func testNodesGetTransactions(txnHash trinary.Hash) error {
} }
func main() { func main() {
config.Load() config.Init()
logger.Load() logger.Init()
InitConfig() InitConfig()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment