utils

package
v0.0.0-...-0c72d35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Black uint8 = iota + 30
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

Foreground colors.

Variables

This section is empty.

Functions

func Colorize

func Colorize(s string, c uint8) string

Colorize colorizes a string by a given color.

func NewLogger

func NewLogger() *zap.SugaredLogger

Instantiate a zap logger.

Types

type Config

type Config struct {
	//Viper uses the mapstructure package under the hood for unmarshaling values.
	ServerURL                  string `mapstructure:"MQTT_SERVER_URL"`
	User                       string `mapstructure:"MQTT_SERVER_USER"`
	Pwd                        string `mapstructure:"MQTT_SERVER_PWD"`
	Retain                     bool   `mapstructure:"MQTT_SERVER_RETAIN"`
	Qos                        byte   `mapstructure:"MQTT_SERVER_QOS"`
	ClientID                   string `mapstructure:"MQTT_CLIENT_ID"`
	KeepAlive                  uint16 `mapstructure:"MQTT_KEEP_ALIVE"`
	RetryDelay                 uint16 `mapstructure:"MQTT_RETRY_DELAY"`
	Area                       string `mapstructure:"AREA"`
	Site                       string `mapstructure:"SITE"`
	RandomDelayBetweenMessages bool   `mapstructure:"RANDOM_DELAY_BETWEEN_MESSAGES"`
	DelayBetweenMessagesMin    uint16 `mapstructure:"DELAY_BETWEEN_MESSAGES_MIN"`
	DelayBetweenMessagesMax    uint16 `mapstructure:"DELAY_BETWEEN_MESSAGES_MAX"`
	GeneratorsNumber           int    `mapstructure:"GENERATORS_NUMBER"`
	GeneratorsLimitNumber      int    `mapstructure:"GENERATORS_NUMBER_LIMIT"`
}

This Config struct will hold all configuration variables of the application that we read from file or environment variables.

func NewConfig

func NewConfig(logger *zap.SugaredLogger) *Config

func (*Config) LoadConfig

func (config *Config) LoadConfig(logger *zap.SugaredLogger)

LoadConfig reads configuration from file or environment variables.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL