Documentation ¶
Index ¶
- Constants
- func ConfigLoad(content string, serializer Serializer) error
- func ConfigLoadFile(path string, ct Serializer) error
- func ConfigLoadReader(reader io.Reader, ct Serializer) error
- func Put(water Water)
- func PutWithName(water Water, name string)
- func RegisterPlugin(lifecycle Lifecycle, p Plugin)
- func Start()
- func TomlLoad(content string) error
- func TomlLoadFile(path string) error
- func TomlLoadReader(reader io.Reader) error
- type BeforeInitPlugin
- type BeforeInitType
- type Configurator
- type Container
- type Cup
- type CupFunc
- type CupSet
- type Ice
- type Init
- type Lifecycle
- type Plugin
- type Plugins
- type Ready
- type Serializer
- type Water
Constants ¶
View Source
const ( DI = "di" Ignore = "-" )
View Source
const ( ErrorType errorDi = iota ErrorMissing ErrorUnexported ErrorTagDotIndex ErrorStopIterator ErrorUnserialize )
Variables ¶
This section is empty.
Functions ¶
func ConfigLoad ¶
func ConfigLoad(content string, serializer Serializer) error
func ConfigLoadFile ¶
func ConfigLoadFile(path string, ct Serializer) error
func ConfigLoadReader ¶
func ConfigLoadReader(reader io.Reader, ct Serializer) error
func PutWithName ¶
func RegisterPlugin ¶
func TomlLoadFile ¶
func TomlLoadReader ¶
Types ¶
type BeforeInitPlugin ¶
type BeforeInitPlugin struct { }
func (*BeforeInitPlugin) Load ¶
func (b *BeforeInitPlugin) Load(path string, ice Ice)
func (*BeforeInitPlugin) Prefix ¶
func (b *BeforeInitPlugin) Prefix() string
func (*BeforeInitPlugin) Priority ¶
func (b *BeforeInitPlugin) Priority() int
type BeforeInitType ¶
type BeforeInitType interface {
BeforeInit() interface{}
}
type Configurator ¶
type Configurator func(Container)
func WithLogger ¶
func WithLogger(logger *log.Logger) Configurator
func WithLoggerVerbose ¶
func WithLoggerVerbose(verbose bool) Configurator
type Container ¶
type Container interface { // 装载配置 Configure(configurators ...Configurator) Container // 注册插件 根据lifecycle决定在哪一层被初始化 RegisterPlugin(lifecycle Lifecycle, p Plugin) // 放入iceMap, 根据插件来注入 PutIce(ice Ice) // 放入cupMap,water名字由容器的默认规则来决定, water必须是指针类型 Put(water Water) // 放入cupMap,water名字自定义 PutWithName(water Water, name string) // 获取除了excludedNames之外 dropType类型的cup GetCup(dropType reflect.Type, excludedNames ...string) (h *Cup) // 根据name获取 dropType类型的cup GetCupWithName(name string, dropType reflect.Type) (h *Cup) // 根据name获取 water GetWaterWithName(name string) Water // 深度遍历cupMap EachCup(cupFunc CupFunc) // 开始根据生命周期初始化 Start() }
func Configure ¶
func Configure(configurators ...Configurator) Container
func NewContainer ¶
func NewContainer(configurators ...Configurator) Container
type Serializer ¶ added in v0.3.0
type Serializer interface { Unmarshal(data []byte, v interface{}) error Marshal(v interface{}) ([]byte, error) }
var ( JSON Serializer = new(jsonSerializer) TOML Serializer = new(tomlSerializer) YAML Serializer = new(yamlSerializer) )
Source Files ¶
Click to show internal directories.
Click to hide internal directories.