conf

package
v0.0.71 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name            string // 服务名
	Version         string // 版本号
	Env             enum.EnvType
	TimeFormat      string   `yaml:"timeFormat"`
	ConfigFileNames []string `yaml:"configFileNames"`
	Server          struct {
		Http Transport
		Rpc  Transport
	}
	ServiceKV map[string]any `yaml:"serviceKV"` // 业务自定义kv
}

App 应用服务相关配置信息

type Config

type Config struct {
	// contains filtered or unexported fields
}

func New

func New(filepath string) *Config

func (*Config) App

func (c *Config) App() App

func (*Config) AppServiceKV

func (c *Config) AppServiceKV() map[string]any

func (*Config) Config

func (c *Config) Config() config

func (*Config) Database

func (c *Config) Database() Database

func (*Config) Log

func (c *Config) Log() Log

func (*Config) Redis

func (c *Config) Redis() Redis

func (*Config) Sync

func (c *Config) Sync(data []byte) error

Sync 局部更新

type Database

type Database struct {
	DryRun bool
	Driver string // mysql
	Source string // root:root@tcp(127.0.0.1:3306)/test
}

type Log

type Log struct {
	Level       enum.LoggerLevel // 日志级别 默认值是 info
	FileSizeMax uint16           `yaml:"fileSizeMax"`             // 单位是MB 默认值是 10MB
	FileAgeMax  uint16           `yaml:"fileAgeMax"`              // 留存天数
	DirPath     string           `validator:"dir" yaml:"dirPath"` // 日志文件夹路径 默认 ./logs
}

Log config model

日志文件名 xxx/logs/${App.Service}-2006-01-01-150405.log

type Redis

type Redis struct {
	Addr         []string // [127.0.0.1:6379, 127.0.0.1:7000]
	Password     string
	ReadTimeout  string `yaml:"readTimeout"`  // 0.2s
	WriteTimeout string `yaml:"writeTimeout"` // 0.2s
}

type Transport

type Transport struct {
	Addr    string // 0.0.0.0:8000
	Timeout string // 1s
}

Transport 传输协议

Jump to

Keyboard shortcuts

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