config

package
v1.3.5-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: Apache-2.0 Imports: 14 Imported by: 33

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DatabaseConfig  = new(Database)
	DatabasesConfig = make(map[string]*Database)
)
View Source
var ApplicationConfig = new(Application)
View Source
var CacheConfig = new(Cache)

CacheConfig cache配置

View Source
var (
	ExtendConfig interface{}
)
View Source
var GenConfig = new(Gen)
View Source
var JwtConfig = new(Jwt)
View Source
var LockerConfig = new(Locker)
View Source
var LoggerConfig = new(Logger)
View Source
var QueueConfig = new(Queue)
View Source
var SslConfig = new(Ssl)

Functions

func GetRedisClient added in v1.3.6

func GetRedisClient() *redis.Client

GetRedisClient 获取redis客户端

func SetRedisClient added in v1.3.6

func SetRedisClient(c *redis.Client)

SetRedisClient 设置redis客户端

func Setup

func Setup(f func(opts ...source.Option) source.Source, options ...source.Option)

Setup 载入配置文件

func Stop

func Stop()

Stop 停止监听

func Watch

func Watch()

Watch 配置监听, 重载时报错,不影响运行 fixme 数据连接 redis连接还没支持动态配置

Types

type Application

type Application struct {
	ReadTimeout   int
	WriterTimeout int
	Host          string
	Port          int64
	Name          string
	JwtSecret     string
	Mode          string
	DemoMsg       string
	EnableDP      bool
}

type Cache added in v1.3.6

type Cache struct {
	Redis  *RedisConnectOptions
	Memory interface{}
}

func (Cache) Setup added in v1.3.6

func (e Cache) Setup() (storage.AdapterCache, error)

Setup 构造cache 顺序 redis > 其他 > memory

type Config

type Config struct {
	Application *Application          `yaml:"application"`
	Ssl         *Ssl                  `yaml:"ssl"`
	Logger      *Logger               `yaml:"logger"`
	Jwt         *Jwt                  `yaml:"jwt"`
	Database    *Database             `yaml:"database"`
	Databases   *map[string]*Database `yaml:"databases"`
	Gen         *Gen                  `yaml:"gen"`
	Cache       *Cache                `yaml:"cache"`
	Queue       *Queue                `yaml:"queue"`
	Locker      *Locker               `yaml:"locker"`
	Extend      interface{}           `yaml:"extend"`
}

Config 配置集合

type DBResolverConfig

type DBResolverConfig struct {
	Sources  []string
	Replicas []string
	Policy   string
	Tables   []string
}

type Database

type Database struct {
	Driver          string
	Source          string
	ConnMaxIdleTime int
	ConnMaxLifeTime int
	MaxIdleConns    int
	MaxOpenConns    int
	Registers       []DBResolverConfig
}

type Gen

type Gen struct {
	DBName    string
	FrontPath string
}

type Jwt

type Jwt struct {
	Secret  string
	Timeout int64
}

type Locker added in v1.3.6

type Locker struct {
	Redis *RedisConnectOptions
}

func (Locker) Empty added in v1.3.6

func (e Locker) Empty() bool

Empty 空设置

func (Locker) Setup added in v1.3.6

func (e Locker) Setup() (storage.AdapterLocker, error)

Setup 启用顺序 redis > 其他 > memory

type Logger

type Logger struct {
	Type      string
	Path      string
	Level     string
	Stdout    string
	EnabledDB bool
}

type Queue added in v1.3.6

type Queue struct {
	Redis  *QueueRedis
	Memory *QueueMemory
}

func (Queue) Empty added in v1.3.6

func (e Queue) Empty() bool

Empty 空设置

func (Queue) Setup added in v1.3.6

func (e Queue) Setup() (storage.AdapterQueue, error)

Setup 启用顺序 redis > 其他 > memory

type QueueMemory added in v1.3.6

type QueueMemory struct {
	PoolSize uint
}

type QueueRedis added in v1.3.6

type QueueRedis struct {
	RedisConnectOptions
	Producer *redisqueue.ProducerOptions
	Consumer *redisqueue.ConsumerOptions
}

type RedisConnectOptions added in v1.3.6

type RedisConnectOptions struct {
	Network    string `yaml:"network" json:"network"`
	Addr       string `yaml:"addr" json:"addr"`
	Username   string `yaml:"username" json:"username"`
	Password   string `yaml:"password" json:"password"`
	DB         int    `yaml:"db" json:"db"`
	PoolSize   int    `yaml:"pool_size" json:"pool_size"`
	Tls        *Tls   `yaml:"tls" json:"tls"`
	MaxRetries int    `yaml:"max_retries" json:"max_retries"`
}

func (RedisConnectOptions) GetRedisOptions added in v1.3.6

func (e RedisConnectOptions) GetRedisOptions() (*redis.Options, error)

type Settings

type Settings struct {
	Settings Config `yaml:"settings"`
}

Settings 兼容原先的配置结构

type Ssl

type Ssl struct {
	KeyStr string
	Pem    string
	Enable bool
	Domain string
}

type Tls added in v1.3.6

type Tls struct {
	Cert string `yaml:"cert" json:"cert"`
	Key  string `yaml:"key" json:"key"`
	Ca   string `yaml:"ca" json:"ca"`
}

Jump to

Keyboard shortcuts

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