configs

package
v0.0.0-...-88cc69c Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetConfig

func SetConfig(c *Config)

Types

type App

type App struct {
	// app name
	Name string `yaml:"name" default:"flexi code"`

	// app version
	Version string `yaml:"version" default:"v1.0.0"`

	Token `yaml:"token"`
}

type Config

type Config struct {
	App     *App     `yaml:"app"`
	Server  *Server  `yaml:"server"`
	Storage *Storage `yaml:"storage"`
	Logger  *Logger  `yaml:"log"`
}

func GetConfig

func GetConfig() *Config

func New

func New() *Config

func (*Config) Init

func (c *Config) Init() error

Init 初始化配置

func (*Config) Notify

func (c *Config) Notify(config *Config)

Notify 通知配置更新

type Configuration

type Configuration interface {
	Prefix() string
	Init(c *Config) error
}

type Listener

type Listener interface {
	// Listen 监听配置变化,o为旧配置,n为新配置
	Listen(c *Config)
}

type Logger

type Logger struct {
	// 日志级别
	Level string `yaml:"level" default:"info"`
}

func (*Logger) Init

func (l *Logger) Init(c *Config) error

func (*Logger) Listen

func (l *Logger) Listen(c *Config)

func (*Logger) Prefix

func (l *Logger) Prefix() string

type Server

type Server struct {
	Debug   *bool  `yaml:"debug" default:"true"`
	Address string `yaml:"address" default:":8100"`
}

func (*Server) Init

func (s *Server) Init(c *Config) error

func (*Server) Prefix

func (s *Server) Prefix() string

type Storage

type Storage struct {
	// show sql
	Debug *bool `yaml:"debug" default:"true"`

	// db driver
	Driver string `yaml:"driver" default:"mysql"`

	// db table name prefix
	TablePrefix string `yaml:"prefix" default:"flexi_"`

	// auto migrate
	AutoMigrate *bool `yaml:"autoMigrate" default:"true"`

	// db connection
	Connection string `yaml:"connection"`
}

func (*Storage) Init

func (s *Storage) Init(c *Config) error

func (*Storage) IsAutoMigrate

func (s *Storage) IsAutoMigrate() bool

func (*Storage) IsDebug

func (s *Storage) IsDebug() bool

func (*Storage) Listen

func (s *Storage) Listen(c *Config)

func (*Storage) Prefix

func (s *Storage) Prefix() string

type Token

type Token struct {
	Secret string `yaml:"secret" default:"flexi_code"`

	Expired uint `yaml:"expired" default:"30"`
}

Jump to

Keyboard shortcuts

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