Documentation ¶
Overview ¶
#> What is summer ?
Summer is a easy tool if you just want a simple IOC/DI framework. Summer work based on tag "sm".
If you want to use summer,you must put stone to the summer basket first,
and you must call "Start",then summer can work for you.
#> What is Stone ?
Stone is go stone,like bean is javabean.
#> What is basket ?
A container to store stone,and resolve stones dependents.
Index ¶
- Variables
- func Add(name string, stone Stone, value ...interface{})
- func AddNotStrict(name string, stone Stone, value ...interface{})
- func DynamicTomlFile(path string, solver tdc.ResourceSolver, listener tdc.Listener) error
- func FailFastConfig(path string, resolverAddr string)
- func PluginRegister(p Plugin, pt PluginWorkTime)
- func Put(stone Stone, value ...interface{})
- func PutNotStrict(stone Stone, value ...interface{})
- func SetLogLevel(logLevel LogLevel)
- func ShutDown()
- func Start()
- func Strict()
- func Toml(src string) error
- func TomlFile(path string) error
- func Work()
- type Basket
- func (basket *Basket) Add(name string, stone Stone)
- func (basket *Basket) AddNotStrict(name string, stone Stone, value interface{})
- func (basket *Basket) AddWithValue(name string, stone Stone, root interface{}, ignoreStrict bool)
- func (basket *Basket) Each(fn func(holder *Holder))
- func (basket *Basket) EachHolder(fn func(name string, holder *Holder) bool)
- func (basket *Basket) GetStone(name string, t reflect.Type) (stone Stone)
- func (basket *Basket) GetStoneByType(typ interface{}) (result Stone)
- func (basket *Basket) GetStoneHolder(name string, t reflect.Type) (h *Holder)
- func (basket *Basket) GetStoneHolderWithName(name string) *Holder
- func (basket *Basket) GetStoneWithName(name string) (stone Stone)
- func (basket *Basket) PluginRegister(plugin Plugin, t PluginWorkTime)
- func (basket *Basket) Put(stone Stone)
- func (basket *Basket) PutDelayField(field *DelayedField)
- func (basket *Basket) PutNotStrict(stone Stone, value interface{})
- func (basket *Basket) PutWithValue(stone Stone, root interface{}, ignoreStrict bool)
- func (basket *Basket) SafeEach(fn func(holder *Holder))
- func (basket *Basket) ShutDown()
- func (basket *Basket) Start()
- func (basket *Basket) Strict()
- type DelayedField
- type Destroy
- type FieldReferencePlugin
- type Holder
- type Init
- type LogLevel
- type Plugin
- type PluginWorkTime
- type Provider
- type ProviderPlugin
- type Ready
- type SimpleLog
- func (log *SimpleLog) Debug(args ...interface{})
- func (log *SimpleLog) Error(args ...interface{})
- func (log *SimpleLog) Fatal(args ...interface{})
- func (log *SimpleLog) Info(args ...interface{})
- func (log *SimpleLog) Panic(args ...interface{})
- func (log *SimpleLog) Println(args ...interface{})
- func (log *SimpleLog) Warn(args ...interface{})
- type SimpleLogger
- type Stone
- type TomlPlugin
Constants ¶
This section is empty.
Variables ¶
var DefaultBasket = NewBasket()
var FailFastConfigEnvMode = "mode"
var Logger = NewSimpleLogger(InfoLevel)
var NotSupportContainsDot = errors.New("sorry we not support name contains a dot")
var NotSupportStructErr = errors.New("sorry we not support struct now")
Functions ¶
func AddNotStrict ¶
func DynamicTomlFile ¶
func FailFastConfig ¶
func PutNotStrict ¶
func PutNotStrict(stone Stone, value ...interface{})
func SetLogLevel ¶
func SetLogLevel(logLevel LogLevel)
Types ¶
type Basket ¶
type Basket struct {
// contains filtered or unexported fields
}
func (*Basket) AddNotStrict ¶
func (*Basket) AddWithValue ¶
func (*Basket) EachHolder ¶
func (*Basket) GetStoneByType ¶
func (*Basket) GetStoneHolder ¶
get a stone holder from basket
func (*Basket) GetStoneHolderWithName ¶
get a stone holder from basket
func (*Basket) GetStoneWithName ¶
get a stone from basket
func (*Basket) PluginRegister ¶
func (basket *Basket) PluginRegister(plugin Plugin, t PluginWorkTime)
register a plugin to basket
func (*Basket) Put ¶
put a stone into basket ,the stone must be struct's pointer,the stone name will be that's type's name with first character lowercase for example,if stone's type is Foo then the stone will get a name that is "foo"
func (*Basket) PutDelayField ¶
func (basket *Basket) PutDelayField(field *DelayedField)
func (*Basket) PutNotStrict ¶
func (*Basket) PutWithValue ¶
func (*Basket) ShutDown ¶
func (basket *Basket) ShutDown()
shutdown will call all stone's Destroy method
func (*Basket) Start ¶
func (basket *Basket) Start()
start work
1 : summer will resolve the direct dependency ¶
# 2 : summer will call all stones's Init method<br/> if a directly depend on b, b directly depend on c and d ,then a will init after b init,and b will after c and d
# 3 : summer will call all stones's Ready method<br/> if a depend on b, b depend on c and d ,then a will init after b init,and b will after c and d
type DelayedField ¶
type DelayedField struct {
// contains filtered or unexported fields
}
type FieldReferencePlugin ¶
type FieldReferencePlugin struct { }
func (*FieldReferencePlugin) Look ¶
func (plugin *FieldReferencePlugin) Look(holder *Holder, path string, sf *reflect.StructField) reflect.Value
func (*FieldReferencePlugin) Prefix ¶
func (plugin *FieldReferencePlugin) Prefix() string
func (*FieldReferencePlugin) ZIndex ¶
func (plugin *FieldReferencePlugin) ZIndex() int
type Holder ¶
type Holder struct { IgnoreStrict bool Stone Stone Type reflect.Type PointerType reflect.Type Value reflect.Value Basket *Basket Dependencies map[*Holder]bool TagTemplateRootValue interface{} }
a holder that can hold stone
func (*Holder) ResolveDirectlyDependents ¶
func (h *Holder) ResolveDirectlyDependents()
func (*Holder) SetDirectDependValue ¶
func (h *Holder) SetDirectDependValue(fieldValue reflect.Value, field reflect.StructField)
in this step we try to find the stone which the field need
type ProviderPlugin ¶
type ProviderPlugin struct { }
func (*ProviderPlugin) Look ¶
func (plugin *ProviderPlugin) Look(holder *Holder, path string, sf *reflect.StructField) (need reflect.Value)
func (*ProviderPlugin) Prefix ¶
func (plugin *ProviderPlugin) Prefix() string
func (*ProviderPlugin) ZIndex ¶
func (plugin *ProviderPlugin) ZIndex() int
zIndex represent the sequence of plugins
type SimpleLog ¶
type SimpleLog struct { *SimpleLogger // contains filtered or unexported fields }
func NewSimpleLog ¶
type SimpleLogger ¶
type SimpleLogger struct {
// contains filtered or unexported fields
}
func NewSimpleLogger ¶
func NewSimpleLogger(logLevel LogLevel) *SimpleLogger
func (*SimpleLogger) Module ¶
func (logger *SimpleLogger) Module(module string) *SimpleLog
type Stone ¶
type Stone interface{}
a stone is a go stone as you know
func GetStoneByType ¶
func GetStoneByType(typ interface{}) (stone Stone)
type TomlPlugin ¶
type TomlPlugin struct {
// contains filtered or unexported fields
}
func NewTomlPluginByFilePath ¶
func NewTomlPluginByFilePath(path string) (*TomlPlugin, error)
func NewTomlPluginBySource ¶
func NewTomlPluginBySource(src string) (*TomlPlugin, error)
func (*TomlPlugin) Look ¶
func (plugin *TomlPlugin) Look(h *Holder, path string, sf *reflect.StructField) reflect.Value
func (*TomlPlugin) Prefix ¶
func (plugin *TomlPlugin) Prefix() string
func (*TomlPlugin) ZIndex ¶
func (plugin *TomlPlugin) ZIndex() int