config.go 5.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package config
  2. import "time"
  3. type Config struct {
  4. Log Log `mapstructure:"log" json:"log" yaml:"log"`
  5. Serve Serve `mapstructure:"serve" json:"serve" yaml:"serve"`
  6. Mysql Mysql `mapstructure:"mysql" json:"mysql" yaml:"mysql"`
  7. Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"`
  8. AliOss AliOss `mapstructure:"ali-oss" json:"ali-oss" yaml:"ali-oss"`
  9. EsClient EsClient `mapstructure:"es_client" json:"es_client" yaml:"es_client"`
  10. }
  11. // Serve gin服务配置
  12. type Serve struct {
  13. Port int `mapstructure:"port" json:"port" yaml:"port" description:"gin开启监听http服务的端口"`
  14. RunMode string `mapstructure:"run-mode" json:"run-mode" yaml:"run-mode" description:"gin运行模式的默认,枚举值:debug,release"`
  15. UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis" description:"是否使用redis"`
  16. AppName string `mapstructure:"app-name" json:"app-name" yaml:"app-name" description:"项目名称"`
  17. StaticDir string `mapstructure:"static-dir" json:"static-dir" yaml:"static-dir" description:"上传的文件存储目录地址"`
  18. EdbLibUrl string `mapstructure:"edb-lib-url" json:"edb-lib-url" yaml:"edb-lib-url" description:"公共指标库的地址"`
  19. ListenExcelPath string `mapstructure:"listen-excel-path" json:"listen-excel-path" yaml:"listen-excel-path" description:"监听文件夹的路径"`
  20. RefreshTime string `mapstructure:"refresh_time" json:"refresh_time" yaml:"refresh_time" description:"刷新指标数据的时间间隔"`
  21. TerminalCode string `mapstructure:"terminal_code" json:"terminal_code" yaml:"terminal_code" description:"终端代码"`
  22. AppEdbLibNameEn string `mapstructure:"app_edb_lib_name_en" json:"app_edb_lib_name_en" yaml:"app_edb_lib_name_en" description:"公共指标库的英文名称"`
  23. EdbLibMd5Key string `mapstructure:"edb_lib_md5_key" json:"edb_lib_md5_key" yaml:"edb_lib_md5_key" description:"公共指标库的md5值"`
  24. }
  25. // Log 日志配置
  26. type Log struct {
  27. Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix" description:"日志输出前缀"`
  28. LogFile bool `mapstructure:"log-file" json:"logFile" yaml:"log-file" description:""`
  29. Stdout string `mapstructure:"stdout" json:"stdout" yaml:"stdout" description:""`
  30. FileStdout string `mapstructure:"file-stdout" json:"file-stdout" yaml:"file-stdout" description:""`
  31. SaveMaxDay int `mapstructure:"save-max-day" json:"save-max-day" yaml:"save-max-day" description:"最多保留多少天的日志"`
  32. CuttingDay int `mapstructure:"cutting-day" json:"cutting-day" yaml:"cutting-day" description:"相隔几天切割文件"`
  33. LogDirPath string `mapstructure:"log-dir-path" json:"log-dir-path" yaml:"log-dir-path" description:"日志目录"`
  34. LogSoftLink string `mapstructure:"log-soft-link" json:"log-soft-link" yaml:"log-soft-link" description:"日志软链接"`
  35. BinlogDirPath string `mapstructure:"binlog-dir-path" json:"binlog-dir-path" yaml:"binlog-dir-path" description:"binlog日志目录"`
  36. BinlogSoftLink string `mapstructure:"binlog-soft-link" json:"binlog-soft-link" yaml:"binlog-soft-link" description:"binlog日志软链接"`
  37. }
  38. // Mysql 数据库配置
  39. type Mysql struct {
  40. //LogMode bool `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode" description:"是否开启日志"`
  41. Stdout bool `mapstructure:"stdout" json:"stdout" yaml:"stdout" description:"日志是否输出在控制台"`
  42. DefaultDsnAliasName string `mapstructure:"default-dsn-alias-name" json:"default-dsn-alias-name" yaml:"default-dsn-alias-name" description:"默认的数据库连接别名"`
  43. List []MysqlConn `mapstructure:"list" json:"list" yaml:"list" description:"数据库链接配置列表"`
  44. }
  45. // MysqlConn mysql数据链接配置
  46. type MysqlConn struct {
  47. Dsn string `mapstructure:"dsn" json:"dsc" yaml:"dsn" description:"数据库连接配置"`
  48. AliasName string `mapstructure:"alias-name" json:"alias-name" yaml:"alias-name" description:"数据库别名"`
  49. MaxIdleConns int `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns" description:"最大空闲连接"`
  50. MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns" description:"最大连接数"`
  51. }
  52. // Redis redis配置
  53. type Redis struct {
  54. Address string `mapstructure:"address" json:"address" yaml:"address" description:"redis服务链接地址"`
  55. Password string `mapstructure:"password" json:"password" yaml:"password" description:"redis服务密码"`
  56. Db int `mapstructure:"db" json:"db" yaml:"db" description:"默认使用的redis库"`
  57. }
  58. // AliOss aliOss配置
  59. type AliOss struct {
  60. BucketName string `mapstructure:"bucket-name" json:"bucket-name" yaml:"bucket-name"`
  61. EndPoint string `mapstructure:"end-point" json:"end-point" yaml:"end-point"`
  62. ImgHost string `mapstructure:"img-host" json:"img-host" yaml:"img-host" description:"阿里oss主机地址"`
  63. UploadDir string `mapstructure:"upload-dir" json:"upload-dir" yaml:"upload-dir" description:"图片上传的文件目录"`
  64. UploadAudioDir string `mapstructure:"upload-audio-dir" json:"upload-audio-dir" yaml:"upload-audio-dir" description:"视频上传的文件目录"`
  65. AccessKeyId string `mapstructure:"access-key-id" json:"access-key-id" yaml:"access-key-id" description:"access-key-id"`
  66. AccessKeySecret string `mapstructure:"access-key-secret" json:"access-key-secret" yaml:"access-key-secret" description:"access-key-secret"`
  67. }
  68. // EsClient es客户端配置
  69. type EsClient struct {
  70. // 终端地址
  71. Endpoints string `json:"endpoints" yaml:"endpoints"`
  72. // 用户
  73. Username string `json:"username" yaml:"username"`
  74. // 密码
  75. Password string `json:"password" yaml:"password"`
  76. // 超时时间,单位ms
  77. Timeout time.Duration `json:"timeout" yaml:"timeout"`
  78. // es日志目录
  79. Log string `json:"log" yaml:"log"`
  80. // 索引前缀
  81. Prefix string `json:"prefix" yaml:"prefix"`
  82. }