config

package
v0.0.0-...-fc07508 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const EnvPrefix = "APP_SERVER_"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	K       *koanf.Koanf    `json:"-"`
	Stage   string          `json:"stage" yaml:"stage"`
	Logging LoggingConfig   `json:"logging" yaml:"logging"`
	Server  ServerConfig    `json:"server" yaml:"server"`
	DB      database.Config `json:"db" yaml:"db"`
	Cache   cache.Config    `json:"cache" yaml:"cache"`
	Metric  MetricsConfig   `json:"metric" yaml:"metric"`
}

func Load

func Load(configPath string, configMap map[string]interface{}) (*Config, error)

Load loads config with below orders. 1. defaultConfig constants. 2. environment variables having "APP_SERVER_" prefix. 3. config file if provided 4. configMap if not empty.

func (*Config) MarshalJSON

func (c *Config) MarshalJSON() ([]byte, error)

type LoggingConfig

type LoggingConfig struct {
	Level             int    `json:"level" yaml:"level"`
	Encoding          string `json:"encoding" yaml:"encoding"`
	Development       bool   `json:"development" yaml:"development"`
	DisableStacktrace bool   `json:"disable-stacktrace" yaml:"disable-stacktrace"`
}

type MetricsConfig

type MetricsConfig struct {
	Enabled   bool   `json:"enabled" yaml:"enabled"`
	Port      int    `json:"port" yaml:"port"`
	Namespace string `json:"namespace" yaml:"namespace"`
	Subsystem string `json:"subsystem" yaml:"subsystem"`
}

type ServerConfig

type ServerConfig struct {
	Port             int           `json:"port" yaml:"port"`
	ReadTimeout      time.Duration `json:"read-timeout" yaml:"read-timeout"`
	WriteTimeout     time.Duration `json:"write-timeout" yaml:"write-timeout"`
	GracefulShutdown time.Duration `json:"graceful-shutdown" yaml:"graceful-shutdown"`
	Cors             struct {
		AllowAll   bool     `json:"allow-all" yaml:"allow-all"`
		Origin     []string `json:"origin" yaml:"origin"`
		BrowserExt bool     `json:"browser-ext" yaml:"browser-ext"`
	} `json:"cors" yaml:"cors"`
	Docs struct {
		Enabled bool   `json:"enabled" yaml:"enabled"`
		Path    string `json:"path" yaml:"path"`
	} `json:"docs" yaml:"docs"`
	Auth struct {
		JWT struct {
			Realm      string        `json:"realm" yaml:"realm"`
			Key        string        `json:"key" yaml:"key"`
			Timeout    time.Duration `json:"timeout" yaml:"timeout"`
			MaxRefresh time.Duration `json:"max-refresh" yaml:"max-refresh"`
		} `json:"jwt" yaml:"jwt"`
	} `json:"auth" yaml:"auth"`
}

Jump to

Keyboard shortcuts

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