config

package
v0.0.0-...-9e1b110 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALL  = "all"
	WEB  = "web"
	GRPC = "grpc"

	NoPerf = "0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	WorkSpace   string      `toml:"workspace"`
	File        string      `toml:"configfile"`
	Mode        string      `toml:"mode"`
	PerfConfig  PerfConfig  `toml:"PerfConfig"`
	WebConfig   WebConfig   `toml:"WebConfig"`
	GRPCConfig  GRPCConfig  `toml:"GRPCConfig"`
	TraceConfig TraceConfig `toml:"TraceConfig"`
	LogConfig   LogConfig   `toml:"LogConfig"`
	RedisConfig RedisConfig `toml:"RedisConfig"`
	MysqlConfig MysqlConfig `toml:"MysqlConfig"`
	CosConfig   CosConfig   `toml:"CosConfig"`
	// contains filtered or unexported fields
}

Config global config

func LoadFromFile

func LoadFromFile(configFile string) (*Config, error)

LoadFromFile load from configFile

func (*Config) Reload

func (cfg *Config) Reload() error

Reload reload config

type CosConfig

type CosConfig struct {
	BucketURL string `toml:"BucketURL"`
	SecretID  string `toml:"SecretID"`
	SecretKey string `toml:"SecretKey"`
	PassKey   string `toml:"PassKey"`
}

CosConfig config of COS

type GRPCConfig

type GRPCConfig struct {
	HttpPort string `toml:"HttpPort"`
	CertPath string `toml:"CertPath"`
	KeyPath  string `toml:"KeyPath"`
	Host     string `toml:"Host"`
}

GRPCConfig the config of grpc service

type LogConfig

type LogConfig struct {
	File       string `toml:"File"`
	Level      string `toml:"Level"`
	Maxsize    int    `toml:"Maxsize"` //unit is M
	MaxBackups int    `toml:"MaxBackups"`
	Maxage     int    `toml:"Maxage"`
}

LogConfig config of log

type MysqlConfig

type MysqlConfig struct {
	Conns        []SigCon `toml:"Conns"`
	DSN          []string
	MaxIdleConns int `toml:"MaxIdleConns"`
	MaxOpenConns int `toml:"MaxOpenConns"`
}

MysqlConfig the config of mysql

func (MysqlConfig) GenerateDSN

func (mc MysqlConfig) GenerateDSN() []string

GenerateDSN get DSNs

type PerfConfig

type PerfConfig struct {
	// HttpPort of prrof, zero means disable the performance
	HttpPort string `toml:"HttpPort"`
}

PerfConfig the config of web service

type RedisConfig

type RedisConfig struct {
	Network      string `toml:"Network"`
	Addr         string `toml:"Addr"`
	Password     string `toml:"Password"`
	DB           int    `toml:"DB"`
	PoolSize     int    `toml:"PoolSize"`
	MinIdleConns int    `toml:"MinIdleConns"`
	TLSConfig    *tls.Config

	// HA
	SentinelOn        bool     `toml:"SentinelOn"`
	SentinelMaster    string   `toml:"SentinelMaster"`
	SentinelEndpoints []string `toml:"SentinelEndpoints"`
}

RedisConfig the config of redis

type SigCon

type SigCon struct {
	User     string `toml:"User"`
	Password string `toml:"Password"`
	Host     string `toml:"Host"`
	Port     string `toml:"Port"`
	DB       string `toml:"DB"`
}

SigCon config of single mysql db

type TraceConfig

type TraceConfig struct {
	ServiceName   string `toml:"ServiceName"`
	AgentHostPort string `toml:"AgentHostPort"`
}

TraceConfig the config of jaeger tracing

type WebConfig

type WebConfig struct {
	HttpPort    string            `toml:"HttpPort"`
	HttpsPort   string            `toml:"HttpsPort"`
	SSLRedirect bool              `toml:"SSLRedirect"`
	TmplPath    string            `toml:"TmplPath"` // end with '/'
	CertPath    string            `toml:"CertPath"`
	KeyPath     string            `toml:"KeyPath"`
	Host        string            `toml:"Host"`
	K8sService  map[string]string `toml:"K8sService"`
}

WebConfig the config of web service

func (*WebConfig) GetDomain

func (wc *WebConfig) GetDomain() string

Jump to

Keyboard shortcuts

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