diff --git a/cmd/live.go b/cmd/live.go index 781162e..48ffa9d 100644 --- a/cmd/live.go +++ b/cmd/live.go @@ -145,13 +145,13 @@ func runGloomberg(_ *cobra.Command, _ []string) { // var seawa *seawatcher.SeaWatcher if viper.GetBool("seawatcher.enabled") || viper.GetBool("listings.enabled") { - var oopenseaAPIKey string + var openseaAPIKey string if key := viper.GetString("api_keys.opensea"); key != "" { - oopenseaAPIKey = viper.GetString("api_keys.opensea") + openseaAPIKey = viper.GetString("api_keys.opensea") } else if key := viper.GetString("seawatcher.api_key"); key != "" { - oopenseaAPIKey = viper.GetString("seawatcher.api_key") + openseaAPIKey = viper.GetString("seawatcher.api_key") } - seawa = seawatcher.NewSeaWatcher(oopenseaAPIKey, gb) + seawa = seawatcher.NewSeaWatcher(openseaAPIKey, gb) } // trapri | ttx printer to process and format the token transactions @@ -563,6 +563,7 @@ func init() { //nolint:gochecknoinits viper.SetDefault("trapri.numOpenSeaEventhandlers", 3) // eventhub + viper.SetDefault("gloomberg.terminalPrinter.numWorker", 1) viper.SetDefault("gloomberg.eventhub.numHandler", 1) viper.SetDefault("gloomberg.eventhub.inQueuesSize", 256) viper.SetDefault("gloomberg.eventhub.outQueuesSize", 32) diff --git a/internal/nemo/gloomberg/gloomberg.go b/internal/nemo/gloomberg/gloomberg.go index 270075f..0a71763 100644 --- a/internal/nemo/gloomberg/gloomberg.go +++ b/internal/nemo/gloomberg/gloomberg.go @@ -118,7 +118,10 @@ func New() *Gloomberg { } clientName := hostname + "_gloomberg_v" + internal.GloombergVersion - redisClientOptions := rueidis.ClientOption{InitAddress: []string{connectAddr}, ClientName: clientName} + redisClientOptions := rueidis.ClientOption{ + InitAddress: []string{connectAddr}, + ClientName: clientName, + } rdb := getRedisClient(redisClientOptions) @@ -141,22 +144,25 @@ func New() *Gloomberg { // // start central terminal printer - go func() { - gbl.Log.Debug("starting terminal printer...") + printToTerminalChannel := gb.SubscribePrintToTerminal() - printToTerminalChannel := gb.SubscribePrintToTerminal() + // experimental: start multiple terminal printers + for i := 0; i < viper.GetInt("gloomberg.terminalPrinter.numWorker"); i++ { + go func() { + gbl.Log.Debug("starting terminal printer...") - for eventLine := range printToTerminalChannel { - gbl.Log.Debugf("terminal printer eventLine: %s", eventLine) + for eventLine := range printToTerminalChannel { + gbl.Log.Debugf("terminal printer eventLine: %s", eventLine) - if viper.GetBool("log.debug") { - debugPrefix := fmt.Sprintf("%d | ", len(printToTerminalChannel)) - eventLine = fmt.Sprint(debugPrefix, eventLine) - } + if viper.GetBool("log.debug") { + debugPrefix := fmt.Sprintf("%d | ", len(printToTerminalChannel)) + eventLine = fmt.Sprint(debugPrefix, eventLine) + } - fmt.Println(eventLine) - } - }() + fmt.Println(eventLine) + } + }() + } // load print configurations to pretty style prints from our different "modules" gb.PrintConfigurations = make(map[string]*printConfig)