Documentation ¶
Index ¶
- func Bootstrap[T Runable](opts ...BuildOption) error
- func Build[T any](ctx context.Context, opts ...BuildOption) (T, error)
- func Default() di.Registry
- func EncodeFlags(w io.Writer) (err error)
- func FlagSet(name ...string) *flag.FlagSet
- func Invoke[T any](ctx context.Context) T
- func OptionFunc[T, K any](fn func(ctx context.Context, option K) (T, error)) *di.InjectBuilder[T, K]
- func Provide[T any](fn any, opts ...Option)
- func SetConfig(items []ConfigItem, source flagx.Source) error
- func SetEnvPrefix(prefix string)
- type All
- type BuildOption
- type Builder
- type ConfigItem
- type ConfigLoader
- type InitFunc
- type Option
- type Retrofiter
- type Runable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bootstrap ¶
func Bootstrap[T Runable](opts ...BuildOption) error
Bootstrap use to build and run a object it will block until the object is stopped
func Build ¶
func Build[T any](ctx context.Context, opts ...BuildOption) (T, error)
Build 递归构建对象以及对象的依赖 注意:Build 只能被调用一次,否则会引发重复注册配置文件以及重复解析参数的Panic
func OptionFunc ¶
func SetEnvPrefix ¶
func SetEnvPrefix(prefix string)
Types ¶
type BuildOption ¶
type BuildOption interface {
// contains filtered or unexported methods
}
func UseConfigLoader ¶ added in v1.1.0
func UseConfigLoader(name string, loader ConfigLoader) BuildOption
UseConfigLoader register a config loader of the given name if name is empty, the loader's type name will be used as the name the loader is ordered by the order of the UseConfigLoader call and the earlier added loader has a higher priority. all loader will be invoked before all init function and build function
func UseInit ¶
func UseInit(name string, fn InitFunc) BuildOption
type ConfigItem ¶ added in v1.1.0
type ConfigLoader ¶
type ConfigLoader interface { // Load load config from config file or other source, // setter is a callback function to set config, it is goroutine safe, // that means you can call setter immediately, // then start a goroutine to watch config change until context done, // and call setter again when config changed Load(ctx context.Context, setter func([]ConfigItem)) error }
ConfigLoader defined a interface to load config
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithOptional ¶ added in v1.1.0
func WithOverride ¶
func WithOverride() Option
func WithSelect ¶
WithSelect 仅供在ProvideInject时使用,可以指定注入某个类型的名字
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
config
|
|
apolloconfig
Package apolloconfig APOLLO配置加载器
|
Package apolloconfig APOLLO配置加载器 |
Click to show internal directories.
Click to hide internal directories.