config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterTSL

type ClusterTSL struct {
	Cert string
	Key  string
}

type Config

type Config struct {
	Path string
	Data ConfigData
	Once sync.Once // 实现单例模式
	Lock sync.RWMutex
}

func (*Config) GetAddress

func (c *Config) GetAddress() string

func (*Config) GetConfigData

func (c *Config) GetConfigData() ConfigData

func (*Config) GetHttpVersion

func (c *Config) GetHttpVersion() string

func (*Config) GetTSL

func (c *Config) GetTSL() *ClusterTSL

func (*Config) IsAuth

func (c *Config) IsAuth() bool

func (*Config) IsHttp2

func (c *Config) IsHttp2() bool

func (*Config) IsHttps

func (c *Config) IsHttps() bool

func (*Config) IsLog

func (c *Config) IsLog() bool

func (*Config) LoadConfigFile

func (c *Config) LoadConfigFile(path string) IConfig

error code 1000 ~ 1200

func (*Config) ReloadConfigFile

func (c *Config) ReloadConfigFile()

重新加载配置文件

func (*Config) SetTSL

func (c *Config) SetTSL(tsl *ClusterTSL) error

type ConfigData

type ConfigData struct {
	Cluster struct {
		Host        string
		Port        int
		Log         bool   // 日志记录
		Auth        bool   // 鉴权
		HttpVersion string `toml:"httpVersion",yaml:"httpVersion"` // 1.0, 1.1, 2.0
		Openssl     bool   // https
		TLS         struct {
			Cert string
			Key  string
		}
	}
	Mysql struct {
		Host         string
		Port         int
		Username     string
		Password     string
		Dbname       string
		Charset      string
		MaxOpenConns int `toml:"maxOpenConns",yaml:"maxOpenConns"`
	}
	Memcache struct {
		Host string
		Port int
	}
	Redis struct {
		Host    string
		Port    int
		Timeout int
	}
}

type ConfigYaml

type ConfigYaml struct {
	Path string
	Data ConfigData
	Once sync.Once // 实现单例模式
	Lock sync.RWMutex
}

func (*ConfigYaml) GetAddress

func (c *ConfigYaml) GetAddress() string

func (*ConfigYaml) GetConfigData

func (c *ConfigYaml) GetConfigData() ConfigData

func (*ConfigYaml) GetHttpVersion

func (c *ConfigYaml) GetHttpVersion() string

func (*ConfigYaml) GetTSL

func (c *ConfigYaml) GetTSL() *ClusterTSL

func (*ConfigYaml) IsAuth

func (c *ConfigYaml) IsAuth() bool

func (*ConfigYaml) IsHttp2

func (c *ConfigYaml) IsHttp2() bool

func (*ConfigYaml) IsHttps

func (c *ConfigYaml) IsHttps() bool

func (*ConfigYaml) IsLog

func (c *ConfigYaml) IsLog() bool

func (*ConfigYaml) LoadConfigFile

func (c *ConfigYaml) LoadConfigFile(path string) IConfig

func (*ConfigYaml) ReloadConfigFile

func (c *ConfigYaml) ReloadConfigFile()

重新加载配置文件

func (*ConfigYaml) SetTSL

func (c *ConfigYaml) SetTSL(tsl *ClusterTSL) error

type IConfig

type IConfig interface {
	LoadConfigFile(path string) IConfig
	ReloadConfigFile()
	SetTSL(tsl *ClusterTSL) error
	GetTSL() *ClusterTSL
	GetAddress() string
	IsHttps() bool // 是否开启https
	IsLog() bool
	IsAuth() bool // 是否开启鉴权
	IsHttp2() bool
	GetHttpVersion() string
	GetConfigData() ConfigData
}

func NewConfig

func NewConfig() IConfig

load config file singleton

func NewConfigYaml

func NewConfigYaml() IConfig

Jump to

Keyboard shortcuts

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