config

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 5 Imported by: 0

README

配置文件

包括了app服务的配置 CI配置 服务启动配置 服务的自定义配置 通信密钥

Documentation

Overview

Package config

基于configen的配置文件加载实现 默认的配置文件为继承自json的*.pig文件

Index

Constants

View Source
const (
	GlobalConfigRoot = "conf"
	GlobalConfigFile = "apollo.pig"
)

Variables

This section is empty.

Functions

func GetDefault

func GetDefault(ck string) string

GetDefault 设置默认配置

func InitGlobalConfig

func InitGlobalConfig() error

InitGlobalConfig 初始化全局配置文件

func SaveGlobalConfig

func SaveGlobalConfig() error

SaveGlobalConfig 持久化配置

Types

type CI

type CI struct {
	DockerHost       string `json:"docker_host"`
	DockerTimeout    int    `json:"docker_timeout"`
	DockerAPIVersion string `json:"docker_api_version"`
}

CI CI配置

type DConfig

type DConfig struct {
	ServiceRoot string `json:"service_root"`  // 服务架构的根目录
	APPRoot     string `json:"app_root"`      // 整个服务的根目录
	APPManager  string `json:"app_manager"`   // 管理服务所在目录
	APPCacheDir string `json:"app_cache_dir"` // 服务缓存目录
	APPLogDir   string `json:"app_log_dir"`   // 服务日志目录
	APPTmpDir   string `json:"app_tmp_dir"`   // 服务临时文件目录
	APPBackUp   string `json:"app_back_up"`   // 服务备份目录
	APPPidDir   string `json:"app_pid_dir"`   // 服务运行时的pid
	// logger
	Log DLog `json:"log"`

	// DB
	DB DDb `json:"db"`

	// Server
	Server Server `json:"server"`

	// CI
	CI CI `json:"ci"`
	// contains filtered or unexported fields
}

DConfig 全局配置

var ApolloConf DConfig

func (*DConfig) Sync

func (d *DConfig) Sync()

Sync 从配置文件中同步加载

func (*DConfig) ToJSON

func (d *DConfig) ToJSON() string

func (*DConfig) Update

func (d *DConfig) Update(v *DConfig)

Update 安全的更新配置数据

type DDb

type DDb struct {
	Sqlite Sqlite `json:"sqlite"`
	Mongo  Mongo  `json:"mongo"`
	Redis  Redis  `json:"redis"`
}

DDb Database Config

type DLog

type DLog struct {
	EnableLog      string `json:"enable_log"`      // yes | no
	EnableStack    string `json:"enable_stack"`    // default disabled
	EnableFunction string `json:"enable_function"` // default disabled
	EnableCaller   string `json:"enable_caller"`   // default enabled
	LogFile        string `json:"log_file"`        // default stderr
	Encoding       string `json:"encoding"`        // default encoding json/console
}

DLog log config

type Mongo

type Mongo struct {
	Name   string `json:"name"`
	URL    string `json:"url"`
	User   string `json:"user"`
	PassWd string `json:"pass_wd"`
}

type Redis

type Redis struct {
}

type Server

type Server struct {
	Host string `json:"host"`
	Port int    `json:"port"`
	Uds  string `json:"uds"`
}

Server server Config

type Sqlite

type Sqlite struct {
}

Jump to

Keyboard shortcuts

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