config

package
v0.1.37 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 26 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// Dev 开发环境
	Dev = "dev"
	// Test 测试环境
	Test = "test"
	// Gray 灰度环境
	Gray = "gray"
	// Production 正式环境
	Production = "production"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppEnv

type AppEnv string

func AppEnvFromStr

func AppEnvFromStr(e string) AppEnv

func (AppEnv) String

func (e AppEnv) String() string

type Conf

type Conf struct {
	AppEnv  AppEnv `yaml:"app_env"`
	AppName string `yaml:"app_name"`

	Server    *ServerConf              `yaml:"server"`
	Log       *LogConf                 `yaml:"logger"`
	Databases map[string]*DataBaseConf `yaml:"databases"`
	File      *File                    `yaml:"file"`
	// contains filtered or unexported fields
}

func NewConf

func NewConf(opts ...ConfOption) *Conf

func (*Conf) Bootstrap

func (c *Conf) Bootstrap() error

func (*Conf) Scan

func (c *Conf) Scan(out interface{}) error

type ConfOption

type ConfOption func(c *Conf)

func WithConfFile

func WithConfFile(path string) ConfOption

type DataBaseConf

type DataBaseConf struct {
	Dsn           string `yaml:"dsn"`
	TablePrefix   string `yaml:"table_prefix"`
	SingularTable bool   `yaml:"singular_table"`
	NoLowerCase   bool   `yaml:"no_lower_case"`
	// contains filtered or unexported fields
}

func (*DataBaseConf) GetDB

func (dc *DataBaseConf) GetDB() (*gorm.DB, error)

type File added in v0.1.8

type File struct {
	Default string `yaml:"default"`
	Local   struct {
		RootDir string `yaml:"root"`
	} `yaml:"local"`
	OSS struct {
		AccessId     string `yaml:"access_id"`
		AccessSecret string `yaml:"access_secret"`
		Bucket       string `yaml:"bucket"`
		Endpoint     string `yaml:"endpoint"`
	} `yaml:"oss"`
	COS struct {
		Region    string `yaml:"region"`
		AppId     string `yaml:"app_id"`
		SecretID  string `yaml:"secret_id"`
		SecretKey string `yaml:"secret_key"`
		Bucket    string `yaml:"bucket"`
	}
}

func (*File) GetBaseUrl added in v0.1.17

func (f *File) GetBaseUrl(path string) string

func (*File) GetStorage added in v0.1.8

func (f *File) GetStorage(workDir string) (*FileStorage, error)

type FileStorage added in v0.1.8

type FileStorage struct {
	// contains filtered or unexported fields
}

func (*FileStorage) DownloadFile added in v0.1.8

func (s *FileStorage) DownloadFile(path string, targetPath string) error

func (*FileStorage) MultiPartDownload added in v0.1.8

func (s *FileStorage) MultiPartDownload(path string, targetFile *os.File, partOffset, partSize int64) error

MultiPartDownload 多块并行下载 todo not final

func (*FileStorage) MultipartUploadByFileHeader added in v0.1.15

func (s *FileStorage) MultipartUploadByFileHeader(fileHeader *multipart.FileHeader, processFunc func(part types.Part)) error

func (*FileStorage) MultipartUploadByPath added in v0.1.15

func (s *FileStorage) MultipartUploadByPath(path string, processFunc func(part types.Part)) error

func (*FileStorage) SetUploadChunkSize added in v0.1.31

func (s *FileStorage) SetUploadChunkSize(chunkSize int64)

func (*FileStorage) Stat added in v0.1.14

func (s *FileStorage) Stat(path string) (*types.Object, error)

func (*FileStorage) UploadByFileHeader added in v0.1.15

func (s *FileStorage) UploadByFileHeader(fileHeader *multipart.FileHeader, processFunc func(bs []byte), auto bool) error

func (*FileStorage) UploadByPath added in v0.1.15

func (s *FileStorage) UploadByPath(path string, processFunc func(bs []byte), auto bool) error

type HttpConf

type HttpConf struct {
	IP   string `yaml:"ip"`
	Port int    `yaml:"port"`
}

type LogConf

type LogConf struct {
	lumberjack.Logger
	LogDir string `yaml:"log_dir"`
}

func (*LogConf) LoggerInit

func (l *LogConf) LoggerInit(isDev bool) (error, func())

LoggerInit 日志初始化

type ServerConf

type ServerConf struct {
	Http HttpConf `yaml:"http"`
}

Jump to

Keyboard shortcuts

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