config

package
v0.0.0-...-a48b4e1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Name string
	// 运行模式 1. debug 2. release, 默认 release
	Mode string
	//是否能访问Api文档, 默认 false
	Doc bool
	//绑定 IP
	Host string `yaml:"host" mapstructure:"host"`
	//绑定 Port
	Port string `yaml:"host" mapstructure:"port"`
}

type Config

type Config struct {
	Path             string           `yaml:"-" mapstructure:"-"`
	AppConfig        AppConfig        `yaml:"app" mapstructure:"app"`
	LoggerConfig     LoggerConfig     `yaml:"logger" mapstructure:"logger"`
	DatabaseConfig   DatabaseConfig   `yaml:"db" mapstructure:"db"`
	Oauth2Config     Oauth2Config     `yaml:"oauth" mapstructure:"oauth"`
	ProbesConfig     ProbesConfig     `yaml:"probes" mapstructure:"probes"`
	PrometheusConfig PrometheusConfig `yaml:"prometheus" mapstructure:"prometheus"`
	TracingConfig    TracingConfig    `yaml:"tracing" mapstructure:"tracing"`
}

func New

func New(path string, prefix string) (*Config, error)

Init 初始化viper

type DatabaseConfig

type DatabaseConfig struct {
	Dialect     string `yaml:"dialect" mapstructure:"dialect"`
	AutoMigrate bool   `yaml:"autoMigrate" mapstructure:"autoMigrate"`

	MysqlOptions  MysqlOptions  `yaml:"mysql" mapstructure:"mysql"`
	SqliteOptions SqliteOptions `yaml:"sqlite" mapstructure:"sqlite"`
	// contains filtered or unexported fields
}

type LoggerConfig

type LoggerConfig struct {
	Filename   string `yaml:"filename" mapstructure:"filename"`
	MaxSize    int    `yaml:"maxSize" mapstructure:"maxSize"`
	MaxBackups int    `yaml:"maxBackups" mapstructure:"maxBackups"`
	MaxAge     int    `yaml:"maxAge" mapstructure:"maxAge"`
	Level      string `yaml:"level" mapstructure:"level"`
	Stdout     bool   `yaml:"stdout" mapstructure:"stdout"`
}

type MysqlOptions

type MysqlOptions struct {
	User     string `yaml:"user" mapstructure:"user"`
	Password string `yaml:"password" mapstructure:"password"`
	Host     string `yaml:"host" mapstructure:"host"`
	Port     int    `yaml:"port" mapstructure:"port"`
	Name     string `yaml:"name" mapstructure:"name"`
	Charset  string `yaml:"charset" mapstructure:"charset"`
}

type Oauth2Config

type Oauth2Config struct {
	Endpoint oauth2.Endpoint `yaml:"endpoint" mapstructure:"endpoint"`
	Config   oauth2.Config   `yaml:"config" mapstructure:"config"`
}

type ProbesConfig

type ProbesConfig struct {
	Enable        bool   `yaml:"enable" mapstructure:"enable"`
	ReadinessPath string `yaml:"readinessPath" mapstructure:"readinessPath"`
	LivenessPath  string `yaml:"livenessPath" mapstructure:"livenessPath"`
	Port          int    `yaml:"port" mapstructure:"port"`
}

type PrometheusConfig

type PrometheusConfig struct {
	//是否开启 Prometheus, 默认 false
	Enable               bool   `yaml:"enable" mapstructure:"enable"`
	Path                 string `yaml:"path" mapstructure:"path"`
	Port                 int    `yaml:"port" mapstructure:"port"`
	CheckIntervalSeconds int    `yaml:"checkIntervalSeconds" mapstructure:"checkIntervalSeconds"`
}

type SqliteOptions

type SqliteOptions struct {
	Name string `yaml:"name" mapstructure:"name"`
}

type TracingConfig

type TracingConfig struct {
	//是否开启 opentracing, 默认 false
	Enable       bool                   `yaml:"enable" mapstructure:"enable"`
	JaegerConfig jagercfg.Configuration `yaml:"jaeger" mapstructure:"jaeger"`
}

Jump to

Keyboard shortcuts

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