config

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConfig

func InitConfig(configName string, configPath string)

Types

type APP

type APP struct {
	Name     string `mapstructure:"name"`
	Version  string `mapstructure:"version"`
	Env      string `mapstructure:"env"`
	Center   string `mapstructure:"center"`
	Register bool   `mapstructure:"register"`
}

type Captcha

type Captcha struct {
	Enabled   bool `mapstructure:"enabled"`
	StoreMode int8 `mapstructure:"storeMode"`
	Len       int  `mapstructure:"len"`
	Width     int  `mapstructure:"width"`
	Height    int  `mapstructure:"height"`
}

type Config

type Config struct {
	APP        APP        `mapstructure:"app"`
	Mysql      Mysql      `mapstructure:"mysql"`
	Redis      Redis      `mapstructure:"redis"`
	Log        Log        `mapstructure:"log"`
	HTTPServer HTTPServer `mapstructure:"httpServer"`
	FilePath   FilePath   `mapstructure:"filePath"`
	Minio      Minio      `mapstructure:"minio"`
	Captcha    Captcha    `mapstructure:"captcha"`
	RpcXServer RpcXServer `mapstructure:"rpcServer"`
}

func Get

func Get() Config

type FilePath

type FilePath struct {
	AgentRootPath  string `mapstructure:"agentRootPath"`
	MountPath      string `mapstructure:"mountPath"`
	MountSubPath   string `mapstructure:"mountSubPath"`
	KubeConfigPath string `mapstructure:"kubeConfigPath"`
}

type HTTPServer

type HTTPServer struct {
	Address   string `mapstructure:"address"`
	Port      int    `mapstructure:"port"`
	Mode      string `mapstructure:"mode"`
	MachineIp string `mapstructure:"machineIp"`
}

type Log

type Log struct {
	Level       string      `mapstructure:"level"`
	Stdout      bool        `mapstructure:"stdout"`
	LogRate     bool        `mapstructure:"logRate"`
	LogRateConf LogRateConf `mapstructure:"logRateConf"`
}

type LogRateConf

type LogRateConf struct {
	MaxAge     int  `mapstructure:"maxAge"`
	MaxBackups uint `mapstructure:"maxBackups"`
	MaxSize    uint `mapstructure:"maxSize"`
}

type Minio

type Minio struct {
	Host      string `mapstructure:"host"`
	AccessKey string `mapstructure:"accessKey"`
	Secret    string `mapstructure:"secret"`
}

type Mysql

type Mysql struct {
	User            string        `mapstructure:"user"`
	Password        string        `mapstructure:"password"`
	Addr            string        `mapstructure:"addr"`
	Port            int           `mapstructure:"port"`
	Database        string        `mapstructure:"database"`
	MaxOpenConn     int           `mapstructure:"maxOpenConn"`
	MaxIdleConn     int           `mapstructure:"maxIdleConn"`
	ConnMaxLifeTime time.Duration `mapstructure:"connMaxLifeTime"`
	LogLevel        int           `mapstructure:"logLevel"`
}

type Options

type Options struct {
	ComponentConfig Config
	WebServer       *core.WebServer
	RpcXServer      *core.RpcXServer
	Db              *gorm.DB
	Redis           *redis.Client
	Minio           *minio.Client
}

func NewOptions

func NewOptions(configName string, configPath string) (*Options, error)

func (*Options) Close

func (o *Options) Close()

Close 关闭服务和资源

func (*Options) Complete

func (o *Options) Complete() error

Complete completes all the required options

func (*Options) RunServer

func (o *Options) RunServer()

RunServer 启动服务

type Redis

type Redis struct {
	Addr       string `mapstructure:"addr"`
	Port       int    `mapstructure:"port"`
	Db         int    `mapstructure:"db"`
	MaxReTries int    `mapstructure:"maxRetries"`
	Password   string `mapstructure:"password"`
	PoolSize   int    `mapstructure:"poolSize"`
}

type RpcXServer

type RpcXServer struct {
	ServerName          string   `mapstructure:"serverName"`
	Address             string   `mapstructure:"address"`
	Port                int      `mapstructure:"port"`
	ReadTimeout         int64    `mapstructure:"readTimeout"`  // 单位秒
	WriteTimeout        int64    `mapstructure:"writeTimeout"` // 单位秒
	EtcdNodes           []string `mapstructure:"etcdNodes"`
	EtcdBasePath        string   `mapstructure:"etcdBasePath"`
	EtcdUpdateInterval  int64    `mapstructure:"etcdUpdateInterval"` // 单位秒
	EtcdExpired         int64    `mapstructure:"etcdExpired"`        // 单位秒
	PondPoolMaxWorkers  int      `mapstructure:"pondPoolMaxWorkers"` // 协程配置,和pondPoolMaxCapacity必须都有值才生效
	PondPoolMaxCapacity int      `mapstructure:"pondPoolMaxCapacity"`
	CertFile            string   `mapstructure:"certFile"`
	KeyFile             string   `mapstructure:"keyFile"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳