cfg

package
v0.0.0-...-2bb37c7 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileTypeYaml = "yaml"
	FileTypeYml  = "yml"
)

Variables

This section is empty.

Functions

func InitCMD

func InitCMD()

func InitConfigFromCMD

func InitConfigFromCMD()

Types

type DataSource

type DataSource struct {
	RDS           RDSConf           `json:"rds"`
	Redis         RedisConf         `json:"redis"`
	Kafka         KafkaConf         `json:"kafka"`
	InfluxDB      InfluxDBConf      `json:"influxdb"`
	ElasticSearch ElasticSearchConf `json:"elasticsearch"`
}

func GetDatasource

func GetDatasource() DataSource

type ElasticSearchConf

type ElasticSearchConf struct {
	Hosts    []string `json:"hosts,omitempty"`
	User     string   `json:"user,omitempty"`
	Password string   `json:"password,omitempty"`
}

func GetES

func GetES() ElasticSearchConf

type FileType

type FileType string

type InfluxDBConf

type InfluxDBConf struct {
	Host     string `json:"host,omitempty"`
	Port     int    `json:"port,omitempty"`
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
}

func GetInfluxDB

func GetInfluxDB() InfluxDBConf

type InnerConfig

type InnerConfig struct {
	DataSource DataSource
}

type KafkaConf

type KafkaConf struct {
	Servers []string `json:"servers,omitempty"`
}

func GetKafka

func GetKafka() KafkaConf

type Manager

type Manager struct {
	*viper.Viper
	// contains filtered or unexported fields
}

func GetConfig

func GetConfig() *Manager

func NewManager

func NewManager(options ...Option) *Manager

func (*Manager) GetDatasource

func (m *Manager) GetDatasource() DataSource

type Option

type Option struct {
	NeedDatasource bool
	Path           string
	FileType       FileType
	ConfigList     []string
}

func NewDefaultOption

func NewDefaultOption() Option

func NewOption

func NewOption(optFn ...OptionFn) Option

type OptionFn

type OptionFn func(opt *Option)

func WithConfigList

func WithConfigList(configList []string) OptionFn

func WithFileType

func WithFileType(fileType FileType) OptionFn

func WithPath

func WithPath(path string) OptionFn

func WithoutDatasource

func WithoutDatasource() OptionFn

type RDSConf

type RDSConf struct {
	Connection RDSConnection `json:"connection"`
	Database   string        `json:"database"`
	Dialect    string        `json:"dialect"`
	Debug      bool          `json:"debug"`
}

type RDSConnection

type RDSConnection struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	Charset  string `json:"charset"`
}

type RDSSetting

type RDSSetting struct {
	Verbose        bool `json:"verbose"`
	MaxConnections int  `json:"max_connections"`
	PoolRecycle    int  `json:"pool_recycle"`
}

type RedisConf

type RedisConf struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Password string `json:"password"`
	DB       int    `json:"db"`
}

func GetRedis

func GetRedis() RedisConf

Jump to

Keyboard shortcuts

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