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)
- func PluginRegister(p Plugin, pt PluginWorkTime)
- func Put(stone Stone)
- func SetLogLevel(logLevel LogLevel)
- func ShutDown()
- func Start()
- func Toml(src string) error
- func TomlFile(path string) error
- type Basket
- func (this *Basket) Add(name string, stone Stone)
- func (this *Basket) Each(fn func(holder *Holder))
- func (this *Basket) EachHolder(fn func(name string, holder *Holder) bool)
- func (this *Basket) GetStone(name string, t reflect.Type) (stone Stone)
- func (this *Basket) GetStoneHolder(name string, t reflect.Type) (h *Holder)
- func (this *Basket) GetStoneHolderWithName(name string) *Holder
- func (this *Basket) GetStoneWithName(name string) (stone Stone)
- func (this *Basket) PluginRegister(plugin Plugin, t PluginWorkTime)
- func (this *Basket) Put(stone Stone)
- func (this *Basket) PutDelayField(field *DelayField)
- func (this *Basket) ShutDown()
- func (this *Basket) Start()
- type DelayField
- type Destroy
- type Holder
- type Init
- type LogLevel
- type Plugin
- type PluginWorkTime
- type Provider
- type ProviderPlugin
- type Ready
- type RefPlugin
- 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 (sl *SimpleLog) SetLevel(logLevel LogLevel) *SimpleLog
- func (log *SimpleLog) Warn(args ...interface{})
- type SimpleLogger
- type Stone
- type TomlPlugin
Constants ¶
This section is empty.
Variables ¶
var CannotResolveDependencyErr = errors.New("sorry,stone's dependency missed")
var NotSupportContainsDot = errors.New("sorry we not support name contains a dot")
var NotSupportStructErr = errors.New("sorry we not support struct now")
Functions ¶
func SetLogLevel ¶
func SetLogLevel(logLevel LogLevel)
Types ¶
type Basket ¶
type Basket struct {
// contains filtered or unexported fields
}
func (*Basket) EachHolder ¶
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 (this *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 (this *Basket) PutDelayField(field *DelayField)
func (*Basket) ShutDown ¶
func (this *Basket) ShutDown()
shutdown will call all stone's Destroy method
func (*Basket) Start ¶
func (this *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 DelayField ¶
type DelayField struct { Holder *Holder // contains filtered or unexported fields }
type Holder ¶
type Holder struct { Stone Stone Class reflect.Type PointerClass reflect.Type Value reflect.Value Basket *Basket Dependents []*Holder }
a holder that can hold stone
func (*Holder) ResolveDirectlyDependents ¶
func (this *Holder) ResolveDirectlyDependents()
func (*Holder) SetDirectDependValue ¶
func (this *Holder) SetDirectDependValue(fieldValue reflect.Value, fieldInfo reflect.StructField)
in this step we try to find the stone which the field need
type ProviderPlugin ¶
type ProviderPlugin struct { }
func (*ProviderPlugin) Look ¶
func (this *ProviderPlugin) Look(holder *Holder, path string, sf *reflect.StructField) (need reflect.Value)
func (*ProviderPlugin) Prefix ¶
func (this *ProviderPlugin) Prefix() string
func (*ProviderPlugin) ZIndex ¶
func (this *ProviderPlugin) ZIndex() int
zIndex represent the sequence of plugins
type RefPlugin ¶
type RefPlugin struct {
// contains filtered or unexported fields
}
type SimpleLog ¶
type SimpleLog struct {
// 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 (sl *SimpleLogger) Module(module string) *SimpleLog
type Stone ¶
type Stone interface{}
a stone is a go stone as you know
type TomlPlugin ¶
type TomlPlugin struct {
// contains filtered or unexported fields
}
func (*TomlPlugin) Look ¶
func (this *TomlPlugin) Look(h *Holder, path string, sf *reflect.StructField) reflect.Value
func (*TomlPlugin) Prefix ¶
func (this *TomlPlugin) Prefix() string
func (*TomlPlugin) ZIndex ¶
func (this *TomlPlugin) ZIndex() int