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 []config.ConfigItem, source flagx.Source) error
- func SetConfigLoader(defaultFile string, fn func(configFile string) ([]config.ConfigItem, error))
- func SetDefaultConfigFile(file string)
- func SetEnvPrefix(prefix string)
- type BuildOption
- type Builder
- type ConfigLoader
- 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 SetConfig ¶
func SetConfig(items []config.ConfigItem, source flagx.Source) error
SetConfig 设置配置
func SetConfigLoader ¶
func SetConfigLoader(defaultFile string, fn func(configFile string) ([]config.ConfigItem, error))
func SetEnvPrefix ¶
func SetEnvPrefix(prefix string)
Types ¶
type BuildOption ¶
type BuildOption interface {
// contains filtered or unexported methods
}
type ConfigLoader ¶
type ConfigLoader interface {
Load(ctx context.Context, setter func([]jsonconfig.ConfigItem)) error
}
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithOverride ¶
func WithOverride() Option
func WithSelect ¶
WithSelect 仅供在ProvideInject时使用,可以指定注入某个类型的名字
Source Files
¶
Click to show internal directories.
Click to hide internal directories.