initialize

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DEVELOPMENT = "dev"
	TEST        = "test"
	PRODUCT     = "prod"
	InitKey     = "initialize"
)
View Source
const (
	EntityField = "ENTITY"
	ConfigField = "CONFIG"
)

Variables

View Source
var (
	// 此处不是真正的初始化,只是为了让配置中心能够读取到配置
	InitConfig = &initConfig{
		Env: DEVELOPMENT, ConfUrl: "./config.toml",
	}
)

约定大于配置

Functions

func GetConfig

func GetConfig[T any]() *T

func NewInit

func NewInit(conf Config, dao Dao) *initConfig

func ParseTagSetting

func ParseTagSetting(str string, sep string, settings TagSettings, tags []string)

ParseTagSetting default sep ;

func Start

func Start(conf Config, dao Dao, notinit ...string) func(deferf ...func())

func Unmarshal

func Unmarshal(v reflect.Value) error

Types

type AfterSet

type AfterSet struct {
}

type BasicConfig

type BasicConfig struct {
	Module string
}

type CloseFunc

type CloseFunc func() error

type Config

type Config = NeedInit

type ConfigCenterConfig

type ConfigCenterConfig struct {
	NoInject []string
	conf_center.ConfigCenterConfig
}

type ConfigTagSettings

type ConfigTagSettings struct {
	Flag string
	Env  string
}

func ParseConfigTagSettings

func ParseConfigTagSettings(str string) *ConfigTagSettings

func (*ConfigTagSettings) Set

func (c *ConfigTagSettings) Set(index int, value string)

type Dao

type Dao = NeedInit

type DaoConfig

type DaoConfig[D any] interface {
	Build() (*D, CloseFunc)
}

TODO:泛型统一的Dao结构

type DaoEntity

type DaoEntity[C DaoConfig[D], D any] struct {
	Conf   C
	Client *D
	// contains filtered or unexported fields
}

func (*DaoEntity[C, D]) Close

func (d *DaoEntity[C, D]) Close() error

func (*DaoEntity[C, D]) Config

func (d *DaoEntity[C, D]) Config() any

func (*DaoEntity[C, D]) SetEntity

func (d *DaoEntity[C, D]) SetEntity()

type DaoField

type DaoField interface {
	Config() any
	SetEntity()
	io.Closer
}

type DaoFieldCloser

type DaoFieldCloser = io.Closer

type DaoFieldCloser1

type DaoFieldCloser1 interface {
	Close()
}

type DaoTagSettings

type DaoTagSettings struct {
	NotInject  bool
	ConfigName string
}

func ParseDaoTagSettings

func ParseDaoTagSettings(str string) *DaoTagSettings

func (*DaoTagSettings) Set

func (t *DaoTagSettings) Set(index int, value string)

type Env

type Env string

type FileConfig

type FileConfig struct {
	BasicConfig
	Dev, Test, Prod *ConfigCenterConfig
}

type FlagConfig

type FlagConfig struct {
	PreSet
	Watch bool
	AfterSet
}

TODO: 优先级高于EnvConfig

type Generate

type Generate interface {
	Generate() any
}

Deprecated

type NeedInit

type NeedInit interface {
	Init()
}

type NeedInitPlaceholder

type NeedInitPlaceholder struct {
}

type PreSet

type PreSet struct {
	Env, ConfUrl string
}

type TagSettings

type TagSettings interface {
	Set(index int, value string)
}

Jump to

Keyboard shortcuts

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