config

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: Apache-2.0 Imports: 9 Imported by: 32

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 LoggerConfig = new(Logger)
View Source
var QueueConfig = new(Queue)
View Source
var SslConfig = new(Ssl)

Functions

func Setup

func Setup(s source.Source,
	fs ...func())

Setup 载入配置文件

Types

type Application

type Application struct {
	ReadTimeout   int
	WriterTimeout int
	Host          string
	Port          int64
	Name          string
	Mode          string
	DemoMsg       string
	EnableDP      bool
	// 租户模式:1:单租户 2:多租户
	TenantMode int `yaml:"tenantMode"`
}

type Cache

type Cache struct {
	Memory interface{}
}

func (Cache) Setup

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

Setup 构造cache 顺序 其他 > 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"`
	Extend      interface{}           `yaml:"extend"`
}

Config 配置集合

func GetConfig added in v1.6.0

func GetConfig() *Config

GetConfig 获取配置对象 返回当前加载的框架配置,如果未初始化则返回 nil

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 Logger

type Logger struct {
	Type         string          `yaml:"type"`
	Adapter      string          `yaml:"adapter"`
	Path         string          `yaml:"path"`
	Level        string          `yaml:"level"`
	Stdout       string          `yaml:"stdout"`
	Encoder      string          `yaml:"encoder"`
	EnableCaller bool            `yaml:"enableCaller"`
	EnabledDB    bool            `yaml:"enableddb"`
	Cap          uint            `yaml:"cap"`
	Rotation     *RotationConfig `yaml:"rotation"`
}

func (Logger) Setup added in v1.6.0

func (e Logger) Setup()

Setup 设置logger(使用新的 logger 架构)

type Queue added in v1.6.0

type Queue struct {
	Memory *QueueMemory
}

func (Queue) Empty added in v1.6.0

func (e Queue) Empty() bool

Empty 空设置

func (Queue) Setup added in v1.6.0

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

Setup 启用顺序 其他 > memory

type QueueMemory added in v1.6.0

type QueueMemory struct {
	PoolSize uint
}

type RotationConfig added in v1.6.4

type RotationConfig struct {
	MaxSize    int  `yaml:"maxSize"`
	MaxAge     int  `yaml:"maxAge"`
	MaxBackups int  `yaml:"maxBackups"`
	Compress   bool `yaml:"compress"`
}

RotationConfig 日志轮转配置

type Settings

type Settings struct {
	Settings Config `yaml:"settings"`
	// contains filtered or unexported fields
}

Settings 兼容原先的配置结构

func (*Settings) Init added in v1.6.0

func (e *Settings) Init()

func (*Settings) OnChange added in v1.6.0

func (e *Settings) OnChange()

type Ssl

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

Jump to

Keyboard shortcuts

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