// Copyright 2019 getensh.com. All rights reserved. // Use of this source code is governed by getensh.com. package config import "encoding/json" type LogConfig struct { Path string `mapstructure:"path"` Level string `mapstructure:"level"` MaxSize json.Number `mapstructure:"max_size"` MaxBackups json.Number `mapstructure:"max_backups"` MaxAge json.Number `mapstructure:"max_age"` Stacktrace string `mapstructure:"stacktrace"` } type MysqlConfig struct { User string `mapstructure:"user"` Password string `mapstructure:"password"` Addr string `mapstructure:"addr"` Db string `mapstructure:"db"` Charset string `mapstructure:"charset"` MaxIdle json.Number `mapstructure:"max_idle"` MaxConn json.Number `mapstructure:"max_conn"` LogMode string `mapstructure:"log_mode"` } type RedisConfig struct { Addrs string `mapstructure:"addrs"` Password string `mapstructure:"password"` Db json.Number `mapstructure:"db"` PoolSize json.Number `mapstructure:"pool_size"` MinIdleConns json.Number `mapstructure:"min_idle_conns"` MaxRetries json.Number `mapstructure:"max_retries"` IsCluster string `mapstructure:"is_cluster"` } type ElasticConfig struct { Addrs string `mapstructure:"addrs"` Sniff string `mapstructure:"sniff"` } type RPCNode struct { ServiceName string `mapstructure:"service_name"` ServicePort json.Number `mapstructure:"service_port"` ServiceIp string `mapstructure:"service_ip"` MysqlDb string `mapstructure:"mysql_db"` RedisDb json.Number `mapstructure:"redis_db"` LogLevel string `mapstructure:"log_level"` LogStacktrace string `mapstructure:"log_stacktrace"` } type KeepaliveConfig struct { ClientTime json.Number `mapstructure:"client_time"` ClientTimeout json.Number `mapstructure:"client_timeout"` ServerTime json.Number `mapstructure:"server_time"` ServerTimeout json.Number `mapstructure:"server_timeout"` ServerMiniTime json.Number `mapstructure:"server_mini_time"` } type RPCConfig struct { Prefix string `mapstructure:"prefix"` Keepalive KeepaliveConfig `mapstructure:"keepalive"` AdmTask RPCNode `mapstructure:"adm_task"` } type MongoConfig struct { User string `mapstructure:"user"` Password string `mapstructure:"password"` Addr string `mapstructure:"addr"` } type OssConfig struct { Endpoint string `mapstructure:"endpoint"` Id string `mapstructure:"id"` Secret string `mapstructure:"secret"` Bucket string `mapstructure:"bucket"` } type Configure struct { // 基础配置 RunMode string `mapstructure:"run_mode" mapstructure:"run_mode"` Log LogConfig `mapstructure:"log"` // 按需配置 Mysql MysqlConfig `mapstructure:"mysql"` Mongo MongoConfig `mapstructure:"mongo"` Redis RedisConfig `mapstructure:"redis"` Elastic ElasticConfig `mapstructure:"elastic"` Oss OssConfig `mapstructure:"oss"` // 所要启用的服务 Rpc RPCConfig `mapstructure:"rpc"` FeildLoopTime json.Number `mapstructure:"feild_loop_time"` }