config

package
v0.0.0-...-3f0bd07 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//环境变量中配置文件路径
	ApplicationEnvVar = "TRAN_TICKET_APP"
	// api.yml文件路径在环境中的变量名
	ApiEnvVar = "TRAN_TICKET_API"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Api

type Api struct {
	Id   string `json:"id" yaml:"id"`
	Name string `json:"name" yaml:"name"`
	Url  string `json:"url" yaml:"url"`
	Get  string `json:"get" yaml:"get"`
}

func (*Api) IsEmpty

func (a *Api) IsEmpty() bool

type ApiConfig

type ApiConfig struct {
	Urls map[string]string `json:"url" yaml:"url"`
	Apis []Api             `json:"api" yaml:"api"`
	// contains filtered or unexported fields
}

func NewApiConfig

func NewApiConfig() *ApiConfig

NewApiConfig 创建ApiConfig

func (*ApiConfig) IsEmpty

func (a *ApiConfig) IsEmpty() bool

func (*ApiConfig) Load

func (a *ApiConfig) Load() error

type ApplicationConfig

type ApplicationConfig struct {
	Environment string
	EnvironmentConfig
	// contains filtered or unexported fields
}

func NewApplicationConfig

func NewApplicationConfig() *ApplicationConfig

func (*ApplicationConfig) Is

func (c *ApplicationConfig) Is(env string) bool

func (*ApplicationConfig) IsDev

func (c *ApplicationConfig) IsDev() bool

func (*ApplicationConfig) IsProd

func (c *ApplicationConfig) IsProd() bool

func (*ApplicationConfig) IsTest

func (c *ApplicationConfig) IsTest() bool

func (*ApplicationConfig) Load

func (c *ApplicationConfig) Load() error

Load 加载配置文件,先尝试从环境变量中的配置文件位置中读取,再尝试从程序所在位置下的config目录中读取

type ConfigContent

type ConfigContent struct {
	Environment    string              `json:"environment" yaml:"environment"`
	Configurations []EnvironmentConfig `json:"configurations" yaml:"configurations"`
}

type Database

type Database struct {
	Name string `json:"name" yaml:"name"`
	Url  string `json:"url" yaml:"url"`
}

type EnvironmentConfig

type EnvironmentConfig struct {
	Profile string `json:"profile" yaml:"profile"`

	Database Database `json:"database" yaml:"database"`

	Server Server `json:"server" yaml:"server"`

	Logger Logger `json:"logger" yaml:"logger"`
}

type LoadState

type LoadState int
const (
	Unload  LoadState = -1 // 未加载
	Loading LoadState = 0  // 加载中
	Loaded  LoadState = 1  // 已加载
)

type Logger

type Logger struct {
	Level        string `json:"level" yaml:"level"`
	Path         string `json:"path" yaml:"path"`
	Filename     string `json:"filename" yaml:"filename"`
	MaxAge       string `json:"maxAge" yaml:"maxAge"`
	RotationTime string `json:"rotationTime" yaml:"rotationTime"`
}

type Server

type Server struct {
	Port string `json:"port" yaml:"port"`
}

Jump to

Keyboard shortcuts

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