Documentation ¶
Index ¶
- Variables
- func Ext(keys string, defVal ...interface{}) interface{}
- func ExtBool(keys string, defVal ...interface{}) bool
- func ExtDuration(keys string, defVal ...interface{}) time.Duration
- func ExtFloat32(keys string, defVal ...interface{}) float32
- func ExtFloat64(keys string, defVal ...interface{}) float64
- func ExtInt(keys string, defVal ...interface{}) int
- func ExtInt16(keys string, defVal ...interface{}) int16
- func ExtInt32(keys string, defVal ...interface{}) int32
- func ExtInt64(keys string, defVal ...interface{}) int64
- func ExtInt8(keys string, defVal ...interface{}) int8
- func ExtString(keys string, defVal ...interface{}) string
- func LoadConf(path string)
- type Config
- func (c *Config) Ext(keys string, defaultVal ...interface{}) interface{}
- func (c *Config) ExtBool(keys string, defaultVal ...interface{}) bool
- func (c *Config) ExtDuration(keys string, defaultVal ...interface{}) time.Duration
- func (c *Config) ExtFloat32(keys string, defaultVal ...interface{}) float32
- func (c *Config) ExtFloat64(keys string, defaultVal ...interface{}) float64
- func (c *Config) ExtInt(keys string, defaultVal ...interface{}) int
- func (c *Config) ExtInt16(keys string, defaultVal ...interface{}) int16
- func (c *Config) ExtInt32(keys string, defaultVal ...interface{}) int32
- func (c *Config) ExtInt64(keys string, defaultVal ...interface{}) int64
- func (c *Config) ExtInt8(keys string, defaultVal ...interface{}) int8
- func (c *Config) ExtSep(keys, sep string) (interface{}, error)
- func (c *Config) ExtString(keys string, defaultVal ...interface{}) string
- type DBSsh
- type Database
- func (d *Database) Ext(key string, defaultVal ...interface{}) interface{}
- func (d *Database) ExtBool(key string, defaultVal ...interface{}) bool
- func (d *Database) ExtDuration(key string, defaultVal ...interface{}) time.Duration
- func (d *Database) ExtInt(key string, defaultVal ...interface{}) int
- func (d *Database) ExtString(key string, defaultVal ...interface{}) string
- type Elasticsearch
- type KafkaConsumer
- type KafkaProducer
- type Log
- type Mongo
- type MongoSafe
- type Redis
Constants ¶
This section is empty.
Variables ¶
View Source
var (
Conf = Config{}
)
Functions ¶
func ExtDuration ¶
ExtDuration is a shorcut for (c *Config) ExtDuration()
func ExtFloat32 ¶
ExtFloat32 is a shorcut for (c *Config) ExtFloat32()
func ExtFloat64 ¶
ExtFloat64 is a shorcut for (c *Config) ExtFloat64()
Types ¶
type Config ¶
type Config struct { LogLevel string `yaml:"logLevel"` Logs []*Log `yaml:"logs,flow"` Mongos []*Mongo `yaml:"mongos,flow"` Elasticsearches []*Elasticsearch `yaml:"elasticsearches,flow"` Redises []*Redis `yaml:"redises,flow"` KafkaProducers []*KafkaProducer `yaml:"kafkaProducers,flow"` KafkaConsumers []*KafkaConsumer `yaml:"kafkaConsumers,flow"` EXT map[string]interface{} `yaml:"ext,flow"` }
func (*Config) Ext ¶
Ext will return the value of the EXT config, the keys is a string separated by DOT(.). If you provide a default value, this method will return the it while the key cannot be found. otherwise it will raise a panic!
func (*Config) ExtDuration ¶
func (*Config) ExtFloat32 ¶
func (*Config) ExtFloat64 ¶
type Database ¶
type Database struct { Key string `yaml:"key"` Addrs []string `yaml:"addrs,flow"` User string `yaml:"user"` Password string `yaml:"password"` DBName string `yaml:"dbName"` EXT map[string]interface{} `yaml:",flow"` }
func (*Database) ExtDuration ¶
type Elasticsearch ¶ added in v1.1.0
type KafkaConsumer ¶
type KafkaConsumer struct { Key string `yaml:"key"` Address []string `yaml:"address"` // kafka地址 Group string `yaml:"group"` // groupId Offset int64 `yaml:"offset"` Ack int `yaml:"ack"` // ack类型 DialTimeout time.Duration `yaml:"dialTimeout"` // How long to wait for the initial connection. ReadTimeout time.Duration `yaml:"readTimeout"` // How long to wait for a response. WriteTimeout time.Duration `yaml:"writeTimeout"` // How long to wait for a transmit. KeepAlive time.Duration `yaml:"keepAlive"` //username and password for SASL/PLAIN or SASL/SCRAM authentication User string `yaml:"user"` Password string `yaml:"password"` }
type KafkaProducer ¶
type KafkaProducer struct { Key string `yaml:"key"` Address []string `yaml:"address"` Async bool `yaml:"async"` ReturnSuccess bool `yaml:"returnSuccess"` ReturnError bool `yaml:"returnError"` //username and password for SASL/PLAIN or SASL/SCRAM authentication User string `yaml:"user"` Password string `yaml:"password"` }
type Log ¶
type Log struct { lumberjack.Logger `yaml:",inline"` OutputEncoder string `yaml:"outputEncoder"` Stdout bool `yaml:"stdout"` FileOut bool `yaml:"fileOut"` HttpOut bool `yaml:"httpOut"` HttpUrl string `yaml:"httpUrl"` // 请求地址 HttpDebug bool `yaml:"httpDebug"` // 是否打印请求输出成功和失败的情况 HttpTimeout int `yaml:"httpTimeout"` // httpclient超时 }
type Mongo ¶ added in v1.1.0
type Mongo struct { Database `yaml:",inline"` AuthSource string `yaml:"authSource"` // 连接管理 Direct bool `yaml:"direct"` ConnectTimeout time.Duration `yaml:"connectTimeout"` //连接超时. 默认为10秒 Keepalive time.Duration `yaml:"keepalive"` //DialInfo.DialServer实现 WriteTimeout time.Duration `yaml:"writeTimeout"` //写超时, 默认为ConnectTimeout ReadTimeout time.Duration `yaml:"readTimeout"` //读超时, 默认为ConnectTimeout Compressors []string `yaml:"compressors,flow"` // 连接池管理 MinPoolSize int `yaml:"minPoolSize"` //对应DialInfo.MinPoolSize MaxPoolSize int `yaml:"maxPoolSize"` //对应DialInfo.PoolLimit MaxPoolWaitTimeMS int `yaml:"maxPoolWaitTimeMS"` //对应DialInfo.PoolTimeout获取连接超时, 默认为0永不超时 MaxPoolIdleTimeMS int `yaml:"maxPoolIdleTimeMS"` //对应DialInfo.MaxIdleTimeMS //读写偏好 Mode string `yaml:"mode"` Safe *MongoSafe `yaml:"safe"` //ssh tune(experimental) Ssh *DBSsh `yaml:"ssh"` }
type MongoSafe ¶ added in v1.1.0
type MongoSafe struct { W int `yaml:"w"` // Min # of servers to ack before success WMode string `yaml:"wMode"` // Write mode for MongoDB 2.0+ (e.g. "majority") RMode string `yaml:"rMode"` // Read mode for MonogDB 3.2+ ("majority", "local", "linearizable") WTimeout int `yaml:"wTimeout"` // Milliseconds to wait for W before timing out FSync bool `yaml:"fSync"` // Sync via the journal if present, or via data files sync otherwise J bool `yaml:"j"` // Sync via the journal if present }
type Redis ¶
type Redis struct { Key string `yaml:"key"` MasterName string `yaml:"masterName"` Addrs []string `yaml:"addrs,flow"` Db int `yaml:"db"` PoolSize int `yaml:"poolSize"` Password string `yaml:"password"` SentinelPassword string `yaml:"sentinelPassword"` DialTimeout string `yaml:"dialTimeout"` ReadTimeout string `yaml:"readTimeout"` WriteTimeout string `yaml:"writeTimeout"` IdleTimeout string `yaml:"idleTimeout"` ReadOnly bool `yaml:"readOnly"` RouteByLatency bool `yaml:"routeByLatency"` RouteRandomly bool `yaml:"routeRandomly"` }
Click to show internal directories.
Click to hide internal directories.