conf

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Conf = Config{}
)

Functions

func Ext

func Ext(keys string, defVal ...interface{}) interface{}

func ExtBool

func ExtBool(keys string, defVal ...interface{}) bool

ExtBool is a shorcut for (c *Config) ExtBool()

func ExtDuration

func ExtDuration(keys string, defVal ...interface{}) time.Duration

ExtDuration is a shorcut for (c *Config) ExtDuration()

func ExtFloat32

func ExtFloat32(keys string, defVal ...interface{}) float32

ExtFloat32 is a shorcut for (c *Config) ExtFloat32()

func ExtFloat64

func ExtFloat64(keys string, defVal ...interface{}) float64

ExtFloat64 is a shorcut for (c *Config) ExtFloat64()

func ExtInt

func ExtInt(keys string, defVal ...interface{}) int

ExtInt is a shorcut for (c *Config) ExtInt()

func ExtInt16

func ExtInt16(keys string, defVal ...interface{}) int16

ExtInt16 is a shorcut for (c *Config) ExtInt16()

func ExtInt32

func ExtInt32(keys string, defVal ...interface{}) int32

ExtInt32 is a shorcut for (c *Config) ExtInt32()

func ExtInt64

func ExtInt64(keys string, defVal ...interface{}) int64

ExtInt64 is a shorcut for (c *Config) ExtInt64()

func ExtInt8

func ExtInt8(keys string, defVal ...interface{}) int8

ExtInt8 is a shorcut for (c *Config) ExtInt8()

func ExtString

func ExtString(keys string, defVal ...interface{}) string

ExtString is a shorcut for (c *Config) ExtString()

func LoadConf

func LoadConf(path string)

Types

type Config

type Config struct {
	Log            Log                    `yaml:"log,flow"`
	Databases      []*Database            `yaml:"databases,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

func (c *Config) Ext(keys string, defaultVal ...interface{}) interface{}

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) ExtBool

func (c *Config) ExtBool(keys string, defaultVal ...interface{}) bool

func (*Config) ExtDuration

func (c *Config) ExtDuration(keys string, defaultVal ...interface{}) time.Duration

func (*Config) ExtFloat32

func (c *Config) ExtFloat32(keys string, defaultVal ...interface{}) float32

func (*Config) ExtFloat64

func (c *Config) ExtFloat64(keys string, defaultVal ...interface{}) float64

func (*Config) ExtInt

func (c *Config) ExtInt(keys string, defaultVal ...interface{}) int

func (*Config) ExtInt16

func (c *Config) ExtInt16(keys string, defaultVal ...interface{}) int16

func (*Config) ExtInt32

func (c *Config) ExtInt32(keys string, defaultVal ...interface{}) int32

func (*Config) ExtInt64

func (c *Config) ExtInt64(keys string, defaultVal ...interface{}) int64

func (*Config) ExtInt8

func (c *Config) ExtInt8(keys string, defaultVal ...interface{}) int8

func (*Config) ExtSep

func (c *Config) ExtSep(keys, sep string) (interface{}, error)

Ext will return the value of the EXT config, the keys is separated by the given sep string.

func (*Config) ExtString

func (c *Config) ExtString(keys string, defaultVal ...interface{}) string

type Database

type Database struct {
	Key         string                 `yaml:"key"`
	Type        string                 `yaml:"type"`
	Host        string                 `yaml:"host"`
	Name        string                 `yaml:"name"`
	User        string                 `yaml:"user"`
	Password    string                 `yaml:"password"`
	MinPoolSize int                    `yaml:"minPoolSize"`
	MaxPoolSize int                    `yaml:"maxPoolSize"`
	EXT         map[string]interface{} `yaml:",flow"`
}

func (*Database) Ext

func (d *Database) Ext(key string, defaultVal ...interface{}) interface{}

Get value of given key of Database section.

func (*Database) ExtBool

func (d *Database) ExtBool(key string, defaultVal ...interface{}) bool

func (*Database) ExtDuration

func (d *Database) ExtDuration(key string, defaultVal ...interface{}) time.Duration

func (*Database) ExtInt

func (d *Database) ExtInt(key string, defaultVal ...interface{}) int

func (*Database) ExtString

func (d *Database) ExtString(key string, defaultVal ...interface{}) string

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"`
	LogLevel          string `yaml:"logLevel"`
	Stdout            bool   `yaml:"stdout"`
	FileOut           bool   `yaml:"fileOut"`
}

type Redis

type Redis struct {
	Key          string   `yaml:"key"`
	Addrs        []string `yaml:"addrs,flow"`
	Db           int      `yaml:"db"`
	PoolSize     int      `yaml:"poolSize"`
	Password     string   `yaml:"password"`
	ReadTimeout  string   `yaml:"readTimeout"`
	WriteTimeout string   `yaml:"writeTimeout"`
	IdleTimeout  string   `yaml:"idleTimeout"`
}

Jump to

Keyboard shortcuts

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