config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(conf *MysqlConf) (sqlbuilder.Database, error)

func InitEtcd

func InitEtcd(conf *EtcdConf) (*clientv3.Client, error)

func InitKafkaConsumer

func InitKafkaConsumer(broker, topics []string, group string) (*cluster.Consumer, error)

func InitKafkaProducer

func InitKafkaProducer(addr []string) (sarama.SyncProducer, error)

func InitLog

func InitLog(path string) (*log.Logger, error)

func InitMC

func InitMC(addr []string) *memcache.Client

func InitMongo

func InitMongo(conf *MongoConf) (*mongo.Client, error)

func InitRedis

func InitRedis(conf *RedisConf) redis.Cmdable

Types

type Conf

type Conf struct {
	Mysql   MysqlConf `yaml:"mysql"`
	Tidb    MysqlConf `yaml:"tidb"`
	Mongo   MongoConf `yaml:"mongo"`
	Redis   RedisConf `yaml:"redis"`
	MC      MCConf    `yaml:"mc"`
	Svc     SvcConf   `yaml:"svc"`
	Etcd    EtcdConf  `yaml:"etcd"`
	Kafka   KafkaConf `yaml:"kafka"`
	LogPath LogConf   `yaml:"log_path"`
}

func LoadYaml

func LoadYaml(path string) (*Conf, error)

type EtcdConf

type EtcdConf struct {
	Addr []string `yaml:"addr"`
	TTL  int      `yaml:"ttl"`
}

type KafkaConf

type KafkaConf struct {
	Addr []string `yaml:"addr"`
}

type LogConf

type LogConf struct {
	Api   string `yaml:"api"`
	Exc   string `yaml:"exc"`
	Debug string `yaml:"debug"`
}

type MCConf

type MCConf struct {
	Addr []string `yaml:"addr"`
}

type MongoConf

type MongoConf struct {
	DBName string `yaml:"db_name"`
	Addr   string `yaml:"addr"`
	Type   string `yaml:"type"`
}

type MysqlConf

type MysqlConf struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	DB       string `yaml:"db"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

type RedisConf

type RedisConf struct {
	Addr []string `yaml:"addr"`
	DB   int      `yaml:"db"`
	Type string   `yaml:"type"`
}

type SvcConf

type SvcConf struct {
	Bind string `yaml:"bind"`
	Addr string `yaml:"addr"`
	Name string `yaml:"name"`
}

Jump to

Keyboard shortcuts

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