config.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package config
  4. import "encoding/json"
  5. type LogConfig struct {
  6. Path string `json:"path"`
  7. Level string `json:"level"`
  8. MaxSize int `json:"max_size"`
  9. MaxBackups int `json:"max_backups"`
  10. MaxAge int `json:"max_age"`
  11. Stacktrace bool `json:"stacktrace"`
  12. }
  13. type MysqlConfig struct {
  14. User string `json:"user"`
  15. Password string `json:"password"`
  16. Addr string `json:"addr"`
  17. DB string `json:"db"`
  18. Charset string `json:"charset"`
  19. MaxIdle int `json:"max_idle"`
  20. MaxConn int `json:"max_conn"`
  21. LogMode bool `json:"log_mode"`
  22. }
  23. type RedisConfig struct {
  24. Addrs []string `json:"addrs"`
  25. Password string `json:"password"`
  26. DB int `json:"db"`
  27. PoolSize int `json:"pool_size"`
  28. MinIdleConns int `json:"min_idle_conns"`
  29. MaxRetries int `json:"max_retries"`
  30. Cluster bool `json:"cluster"`
  31. }
  32. type ElasticConfig struct {
  33. Addrs []string `json:"addrs"`
  34. Sniff bool `json:"sniff"`
  35. }
  36. type ThirdPartNode struct {
  37. Host string `json:"host"`
  38. AppKey string `json:"app_key"`
  39. AppSecret string `json:"app_secret"`
  40. }
  41. type ThirdPartConfig struct {
  42. PartName ThirdPartNode `json:"part_name"`
  43. }
  44. type RPCNode struct {
  45. ServiceName string `json:"service_name"`
  46. ServicePort int `json:"service_port"`
  47. ServiceIp string `json:"service_ip"`
  48. MysqlDb string `json:"mysql_db"`
  49. RedisDb int `json:"redis_db"`
  50. LogLevel string `json:"log_level"`
  51. LogStacktrace bool `json:"log_stacktrace"`
  52. Host string `json:"host"`
  53. }
  54. type KeepaliveConfig struct {
  55. ClientTime int `json:"client_time"`
  56. ClientTimeout int `json:"client_timeout"`
  57. ServerTime int `json:"server_time"`
  58. ServerTimeout int `json:"server_timeout"`
  59. ServerMiniTime int `json:"server_mini_time"`
  60. }
  61. type RPCConfig struct {
  62. Prefix string `json:"prefix"`
  63. Keepalive KeepaliveConfig `json:"keepalive"`
  64. ADMManagement RPCNode `json:"adm_management"`
  65. }
  66. type EtcdConfig struct {
  67. Addrs []string `json:"addrs"`
  68. }
  69. type RabbitmqConfig struct {
  70. Addr string `json:"addr"`
  71. Username string `json:"username"`
  72. Passwrod string `json:"passwrod"`
  73. Vhost string `json:"vhost"`
  74. ExchangeName string `json:"exchange_name"`
  75. QueueName string `json:"queue_name"`
  76. RouteBindKey string `json:"route_bind_key"`
  77. ConsumerCount json.Number `json:"consumer_count"`
  78. }
  79. type Configure struct {
  80. // 基础配置
  81. K8s bool `json:"k8s"`
  82. RunMode string `json:"run_mode"`
  83. Log LogConfig `json:"log"`
  84. // 按需配置
  85. Mysql MysqlConfig `json:"mysql"`
  86. Redis RedisConfig `json:"redis"`
  87. Elastic ElasticConfig `json:"elastic"`
  88. ThirdPart ThirdPartConfig `json:"third_part"`
  89. // 所要启用的服务
  90. Rpc RPCConfig `json:"rpc"`
  91. // etcd
  92. Etcd EtcdConfig `json:"etcd"`
  93. // oss
  94. Oss OssConfig `json:"oss"`
  95. OdsRabbitmq RabbitmqConfig `json:"ods_rabbitmq"`
  96. }
  97. type OssConfig struct {
  98. AccessKey string `json:"access_key"`
  99. AccessSecret string `json:"access_secret"`
  100. Bucket string `json:"bucket"`
  101. EndPoint string `json:"end_point"`
  102. DefaultBrandImage string `json:"default_brand_image"`
  103. BrandImage string `json:"brand_image"`
  104. DefaultSeriesImage string `json:"default_series_image"`
  105. SeriesImage string `json:"series_image"`
  106. DownLoadBucket string `json:"down_load_bucket"`
  107. }