cfg

package
v0.0.0-...-1649e63 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MailerPassword      string `env:"MAILER_SMTP_PASSWORD,required,notEmpty"`
	MailerFallbackToken string `env:"MAILER_FALLBACK_TOKEN,required,notEmpty"`

	MailerFrom         string `env:"MAILER_SMTP_FROM,required,notEmpty"`
	MailerFromFallback string `env:"MAILER_FALLBACK_FROM,required,notEmpty"`

	MailerHost string `env:"MAILER_SMTP_HOST,required,notEmpty"`
	MailerPort int    `env:"MAILER_SMTP_PORT,required,notEmpty"`

	LogLevel string `env:"MAILER_LOG_LEVEL,required,notEmpty"`
	Port     string `env:"MAILER_PORT,required,notEmpty"`
	Host     string `env:"MAILER_HOST"`

	NatsURL  string `env:"NATS_URL,required,notEmpty"`
	MongoURL string `env:"MONGO_URL,required,notEmpty"`

	ConnectTimeout time.Duration `env:"MAILER_TIMEOUT"`
	PrometheusPort string        `env:"PROMETHEUS_PORT,required,notEmpty"`
}

Config struct represents application config, which is used application-wide.

func Must

func Must(cfg *Config, err error) *Config

Must is a handly wrapper around return results from the NewFromEnv() function, which will panic in case of error. Should be called only in main function, when we don't need to handle errors.

func NewFromEnv

func NewFromEnv() (*Config, error)

NewFromEnv parses the environment variables into the Config struct. Returns an error if any of required variables is missing or contains invalid value.

Jump to

Keyboard shortcuts

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