config

package
v0.0.0-...-ab17eec Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: Apache-2.0 Imports: 11 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 {
	Consul   Consul           `mapstructure:",squash"`
	HTTP     HTTP             `mapstructure:",squash"`
	GRPC     GRPC             `mapstructure:",squash"`
	PubSub   PubSub           `mapstructure:",squash"`
	PProf    Pprof            `mapstructure:",squash"`
	Postgres PostgresDatabase `mapstructure:",squash"`
	Redis    Redis            `mapstructure:",squash"`
}

Config project config.

func InitConfig

func InitConfig() Config

InitConfig initializes configuration from .env file and returns config structure.

func (Config) IsValidGRPC

func (c Config) IsValidGRPC() bool

func (Config) IsValidHTTP

func (c Config) IsValidHTTP() bool

func (Config) IsValidSubscriber

func (c Config) IsValidSubscriber() bool

type Consul

type Consul struct {
	Host  string `mapstructure:"CONSUL_HOST"`
	Port  int    `mapstructure:"CONSUL_PORT"`
	Token string `mapstructure:"CONSUL_HTTP_TOKEN"`

	// RuntimeConfig settings
	Key             string        `mapstructure:"CONSUL_KEY"`
	RefreshInterval time.Duration `mapstructure:"CONSUL_REFRESH_INTERVAL"`
}

Consul contains consul remote config related values.

type GRPC

type GRPC struct {
	Port int `mapstructure:"GRPC_PORT"`
}

GRPC contains GRPC related configuration.

type HTTP

type HTTP struct {
	Port             int           `mapstructure:"HTTP_PORT"`
	GracefulDuration time.Duration `mapstructure:"HTTP_GRACEFUL_DURATION"`
}

HTTP contains HTTP related configuration.

type PostgresDatabase

type PostgresDatabase struct {
	DSN                   string          `mapstructure:"DB_POSTGRES_DSN"`
	LogLevel              logger.LogLevel `mapstructure:"DB_POSTGRES_LOG_LEVEL"`
	MaxOpenConnections    int             `mapstructure:"DB_POSTGRES_MAX_OPEN_CONNECTIONS"`
	MaxIdleConnections    int             `mapstructure:"DB_POSTGRES_MAX_IDLE_CONNECTIONS"`
	MaxConnectionLifetime time.Duration   `mapstructure:"DB_POSTGRES_MAX_CONNECTIONS_LIFETIME"`
}

PostgresDatabase contains postgres configuration.

type Pprof

type Pprof struct {
	Enabled bool `mapstructure:"PPROF_ENABLED"`
	Port    int  `mapstructure:"PPROF_PORT"`
}

Pprof contains Pprof project configuration.

type PubSub

type PubSub struct {
	ProjectID   string `mapstructure:"PUBSUB_PROJECT_ID"`
	Credentials string `mapstructure:"PUBSUB_CREDENTIALS"`
}

PubSub contains google PubSub project configuration.

type Redis

type Redis struct {
	Address  string `mapstructure:"REDIS_ADDRESS"`
	Password string `mapstructure:"REDIS_PASSWORD"`
	DB       int    `mapstructure:"REDIS_DB"`
}

Redis contains redis configuration.

Jump to

Keyboard shortcuts

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