config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 10 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 {
	// Captcha 验证码配置
	Captcha *Captcha `mapstructure:"captcha" json:"captcha" yaml:"captcha"`
}

App 应用配置

type Captcha

type Captcha struct {
	// Height 高度
	Height int `mapstructure:"height" json:"height" yaml:"height"`
	// Width 宽度
	Width int `mapstructure:"width" json:"width" yaml:"width"`
	// Length 长度
	Length int `mapstructure:"length" json:"length" yaml:"length"`
}

Captcha 验证码配置

type Channel

type Channel struct {
	// Hystrix 熔断配置
	Hystrix *Hystrix `mapstructure:"hystrix" json:"hystrix" yaml:"hystrix"`
	// Hosts 通道地址
	Hosts []string `mapstructure:"hosts" json:"hosts" yaml:"hosts"`
	// Host 通道地址
	Host string `mapstructure:"host" json:"host" yaml:"host"`
	// Port 通道端口
	Port int `mapstructure:"port" json:"port" yaml:"port"`
	// Token 通道token
	Token string `mapstructure:"token" json:"token" yaml:"token"`
	// Name 通道名称
	Name string `mapstructure:"name" json:"name" yaml:"name"`
	// Database 数据库名
	Database string `mapstructure:"database" json:"database" yaml:"database"`
	// Timeout 超时时间
	Timeout int `mapstructure:"timeout" json:"timeout" yaml:"timeout"`
	// MasterName 主节点
	MasterName string `mapstructure:"master_name" json:"master_name" yaml:"master_name"`
	// Username 用户名
	Username string `mapstructure:"username" json:"username" yaml:"username"`
	// Password 密码
	Password string `mapstructure:"password" json:"password" yaml:"password"`
}

Channel 通道配置

type Client

type Client struct {
	// MySQL MySQL配置
	MySQL *Channel `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
	// Redis Redis配置
	Redis *Channel `mapstructure:"redis" json:"redis" yaml:"redis"`
	// Mongodb mongodb配置
	Mongodb *Channel `mapstructure:"mongodb" json:"mongodb" yaml:"mongodb"`
	// Smtp 邮件配置
	Smtp *Channel `mapstructure:"smtp" json:"smtp" yaml:"smtp"`
}

Client 客户端配置

type Config

type Config struct {
	// Server The address to listen on for HTTP requests.
	Server *Server
	// Client 客户端配置
	Client *Client
	// App 应用配置
	App *App
}

Config is the configuration for the server.

func GetInstance

func GetInstance() *Config

GetInstance 获取配置实例

func (*Config) InitApp

func (o *Config) InitApp(cfg *viper.Viper) error

InitApp 初始化应用配置

func (*Config) InitClient

func (o *Config) InitClient(cfg *viper.Viper) error

InitClient 初始化客户端配置

func (*Config) InitServer

func (o *Config) InitServer(cfg *viper.Viper) error

InitServer 初始化服务配置

type Hystrix

type Hystrix struct {
	// Name 熔断器名称
	Name string `mapstructure:"name" json:"name" yaml:"name"`
	// Timeout 超时时间
	Timeout int `mapstructure:"timeout" json:"timeout" yaml:"timeout"`
	// MaxConcurrent 最大并发数
	MaxConcurrent int `mapstructure:"max_concurrent" json:"max_concurrent" yaml:"max_concurrent"`
	// RequestVolumeThreshold 请求阈值
	RequestVolumeThreshold int `mapstructure:"request_volume_threshold" json:"request_volume_threshold" yaml:"request_volume_threshold"`
	// SleepWindow 熔断时间
	SleepWindow int `mapstructure:"sleep_window" json:"sleep_window" yaml:"sleep_window"`
	// ErrorPercentThreshold 错误百分比
	ErrorPercentThreshold int `mapstructure:"error_percent_threshold" json:"error_percent_threshold" yaml:"error_percent_threshold"`
}

Hystrix 客户端熔断配置

type Log

type Log struct {
	// Level 日志级别
	Level string `mapstructure:"level" json:"level" yaml:"level"`
	// File 日志文件
	File string `mapstructure:"file" json:"file" yaml:"file"`
}

Log 日志配置

type Server

type Server struct {
	// Log 日志配置
	Log *Log `mapstructure:"log" json:"log" yaml:"log"`
	// Hystrix 熔断配置
	Hystrix *Hystrix `mapstructure:"hystrix" json:"hystrix" yaml:"hystrix"`
	// Host 服务地址
	Host string `mapstructure:"host" json:"host" yaml:"host"`
	// Port 端口
	Port int `mapstructure:"port" json:"port" yaml:"port"`
	// Domain 域名
	Domain string `mapstructure:"domain" json:"domain" yaml:"domain"`
}

Server 服务配置

func (*Server) Address

func (o *Server) Address() string

Address 获取服务地址

type Viper

type Viper struct {
	// Path 配置文件路径
	Path string
	// Name 配置文件名称
	Name string
	// Type 配置文件类型
	Type string
	// contains filtered or unexported fields
}

Viper viper配置

func NewViper

func NewViper(name string) *Viper

func (*Viper) Watch

func (o *Viper) Watch(f func(cfg *viper.Viper) error) error

Watch 监听配置文件变化

Jump to

Keyboard shortcuts

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