client

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Host             string `yaml:"host" json:"host"`                         //Redis IP
	Port             int    `yaml:"port" json:"port"`                         //Redis 端口
	User             string `yaml:"user" json:"user"`                         //用户
	Pwd              string `yaml:"pwd" json:"pwd"`                           //密码
	MinFreeConnCount int    `yaml:"minFreeConnCount" json:"minFreeConnCount"` //最小闲置连接数
	MaxOpenConnCount int    `yaml:"maxOpenConnCount" json:"maxOpenConnCount"` //最大连接数, 默认是每核10个连接
	FreeMaxLifetime  int    `yaml:"freeMaxLifetime" json:"freeMaxLifetime"`   //闲置连接存活的最大时间, 单位: 分钟
	Database         int    `yaml:"database" json:"database"`                 //数据库
	ConnectTimeout   int    `yaml:"connectTimeout" json:"connectTimeout"`     //连接Redis超时时间, 单位: 秒
	ReadTimeout      int    `yaml:"readTimeout" json:"readTimeout"`           //读取超时时间, 单位: 秒
	WriteTimeout     int    `yaml:"writeTimeout" json:"writeTimeout"`         //写超时时间, 单位: 秒
	DefaultTimeOut   int    `yaml:"defaultTimeOut" json:"defaultTimeOut"`     //默认缓存时间, 单位: 秒
	MaxRetries       int    `yaml:"maxRetries" json:"maxRetries"`             //最大尝试次数, 默认是3
	MaxConnAge       int    `yaml:"maxConnAge" json:"maxConnAge"`             //连接存活最大时长, 单位: 分钟
}

Cache 缓存配置

type DB

type DB struct {
	Host             string        `yaml:"host" json:"host"`                         //数据库 IP
	Port             int           `yaml:"port" json:"port"`                         //数据库 端口
	User             string        `yaml:"user" json:"user"`                         //用户名
	Password         string        `yaml:"password" json:"password"`                 //密码
	Database         string        `yaml:"database" json:"database"`                 //数据库名
	Location         string        `yaml:"location" json:"location"`                 //时区
	TablePrefix      string        `yaml:"tablePrefix" json:"tablePrefix"`           //表前缀
	SingularTable    bool          `yaml:"singularTable" json:"singularTable"`       //表复数禁用
	CreateBatchSize  int           `yaml:"createBatchSize" json:"createBatchSize"`   //批量创建数量
	EnableRawSQL     bool          `yaml:"enableRawSql" json:"enableRawSql"`         //打印原生SQL
	MaxFreeConnCount int           `yaml:"maxFreeConnCount" json:"maxFreeConnCount"` //最大闲置连接数量
	MaxOpenConnCount int           `yaml:"maxOpenConnCount" json:"maxOpenConnCount"` //最大连接数量
	FreeMaxLifetime  time.Duration `yaml:"freeMaxLifetime" json:"freeMaxLifetime"`   //闲置连接最大存活时间, 单位: 分钟
}

DB 数据库配置

type Log

type Log struct {
	Level         string `json:"level" yaml:"level"`                 //日志级别
	EnableConsole bool   `yaml:"enableConsole" json:"enableConsole"` //日志是否输出到终端
	Rotated       bool   `json:"rotated" yaml:"rotated"`             //日志是否被分割
	FileDir       string `json:"fileDir" yaml:"fileDir"`             //日志文件所在目录
	MaxSize       int    `json:"maxSize" yaml:"maxSize"`             //每个日志文件长度的最大大小,默认100M
	MaxAge        int    `json:"maxAge" yaml:"maxAge"`               //日志保留的最大天数(只保留最近多少天的日志)
	MaxBackups    int    `json:"maxBackups" yaml:"maxBackups"`       //只保留最近多少个日志文件,用于控制程序总日志的大小
	LocalTime     bool   `json:"localtime" yaml:"localtime"`         //是否使用本地时间,默认使用UTC时间
	Compress      bool   `json:"compress" yaml:"compress"`           //是否压缩日志文件,压缩方法gzip
}

Log 日志配置

type Mongo

type Mongo struct {
	//Uri mongo Uri example:"mongodb://localhost:27017"
	Uri string `json:"uri" yaml:"uri"`
	//Database 数据库
	Database string `json:"database" yaml:"database"`
	//MaxConnectCount 最大连接数量
	MaxConnectCount uint64 `json:"maxConnectCount" yaml:"maxConnectCount"`
	//MinFreeConnCount 最小闲置连接数
	MinFreeConnCount uint64 `json:"minFreeConnCount" yaml:"minFreeConnCount"`
	//FreeMaxLifetime 闲置连接最大存活时间, 单位: 分钟
	FreeMaxLifetime int `yaml:"freeMaxLifetime" json:"freeMaxLifetime"`
}

type Setting

type Setting struct {
	Host            string            `json:"host" yaml:"host"`                       //地址
	Port            int               `json:"port" yaml:"port"`                       //端口
	Language        string            `json:"language" yaml:"language"`               //校验错误返回的语言
	ShutDownTimeout int               `json:"shutDownTimeout" yaml:"shutDownTimeout"` //优雅重启, 接收到相关信号后, 处理请求的最长时间, 单位: 秒, 默认5s
	Application     string            `json:"application" yaml:"application"`         //应用名
	Debug           bool              `json:"debug" yaml:"debug"`                     //debug
	Swagger         bool              `json:"swagger" yaml:"swagger"`                 //是否启动swagger
	LogConfig       Log               `json:"log" yaml:"log"`                         //日志配置
	Middlewares     []gin.HandlerFunc //中间件
	OnStartUp       []func() error    //项目启动前执行函数
	OnShutDown      []func() error    //项目关闭前执行函数
}

func (*Setting) Arrange

func (s *Setting) Arrange()

Arrange 处理零值及无效字段为默认值

Jump to

Keyboard shortcuts

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