config

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentApp           = "App"
	ComponentDebug         = "Debug"
	ComponentCrypto        = "Crypto"
	ComponentMetrics       = "Metrics"
	ComponentLog           = "Log"
	ComponentDB            = "DB"
	ComponentRedis         = "Redis"
	ComponentMongo         = "Mongo"
	ComponentI18n          = "I18n"
	ComponentLock          = "Lock"
	ComponentMessageQueue  = "MQ"
	ComponentHttp          = "Http"
	ComponentCache         = "Cache"
	ComponentCron          = "Cron"
	ComponentAsync         = "Async"
	ComponentGoroutinePool = "GoroutinePool"
)

common component names

View Source
const (
	DefaultInstanceKey = "default"
)

Variables

View Source
var (
	Registry = &registry{di: di.Dig, initOnce: new(sync.Once), closeCh: make(chan struct{})}
)

Functions

func AddComponent

func AddComponent(name string, constructor any, opts ...ComponentOption)

func AppName

func AppName(name string) utils.OptionFunc[InitOption]

func CryptoConfigName

func CryptoConfigName(name string) utils.OptionFunc[cryptoConfigOption]

func CryptoConstruct

func CryptoConstruct(ctx context.Context, c CryptoConf, _ ...utils.OptionExtender) func()

func CryptoDecryptByTag

func CryptoDecryptByTag(data any, opts ...utils.OptionExtender)

func CryptoDecryptFunc

func CryptoDecryptFunc(opts ...utils.OptionExtender) func(src string) (dst string)

func CryptoEncryptFunc

func CryptoEncryptFunc(opts ...utils.OptionExtender) func(src string) (dst string)

func Ctx

func Ctx(ctx context.Context) utils.OptionFunc[initOption]

func DI

func Debug

func Debug() utils.OptionFunc[initOption]

func Files

func Files(filenames []string) utils.OptionFunc[initOption]

func Loader

func Loader(fn func(any, ...utils.OptionExtender)) utils.OptionFunc[initOption]

func NewDefaultLoader

func NewDefaultLoader(files ...string) *loader

NewDefaultLoader front files overwrite the backs

Types

type Component

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

func (*Component) Clone

func (c *Component) Clone() (r *Component)

type ComponentOption

type ComponentOption func(*options)

func WithCore

func WithCore() ComponentOption

WithCore mark component as core component, they must be init first

func WithFlag added in v0.0.64

func WithFlag(flagValue *string) ComponentOption

func WithTag

func WithTag(name, val string) ComponentOption

WithTag set component struct tags

type Configurable

type Configurable interface {
	Init(businessConfig any, opts ...utils.OptionExtender) (gracefully func())
	LoadComponentConfig(name string, componentConfig any) (err error)
	GetAllConfigs() any
	Debug() (debug bool)
	AppName() (name string)
	DI() di.DI
}

func New

func New(appName string) Configurable

func Use

func Use(appName string, opts ...utils.OptionExtender) Configurable

type CryptoConf

type CryptoConf struct {
	Config *cryptoConf            `yaml:"config" json:"config" toml:"config"`
	Custom map[string]*cryptoConf `yaml:"custom" json:"custom" toml:"custom"`
}

func (*CryptoConf) ToOptionMap

func (c *CryptoConf) ToOptionMap() (result map[string][]utils.OptionExtender)

type InitOption

type InitOption struct {
	DI      di.DI
	AppName string
}

Jump to

Keyboard shortcuts

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