Documentation ¶
Index ¶
- Constants
- Variables
- func Call(receiver interface{})
- func DisableDebugLogging()
- func EnableDebugLogging()
- func Fill(receiver interface{})
- func Instance(resolver interface{})
- func NamedInstance(name string, resolver interface{})
- func NamedResolve(abstraction interface{}, name string)
- func NamedSingleton(name string, resolver interface{})
- func Reset()
- func Resolve(abstraction interface{})
- func SetErrorHandler(handler errorHandler)
- func SetLogger(logger log.Logger)
- func Singleton(resolver interface{})
- type Injector
- func (injector *Injector) Call(function interface{})
- func (injector *Injector) DisableDebugLogging()
- func (injector *Injector) EnableDebugLogging()
- func (injector *Injector) Fill(structure interface{})
- func (injector *Injector) Instance(provider interface{}) *Injector
- func (injector *Injector) NamedInstance(name string, provider interface{}) *Injector
- func (injector *Injector) NamedResolve(abstraction interface{}, name string)
- func (injector *Injector) NamedSingleton(name string, provider interface{}) *Injector
- func (injector *Injector) Reset()
- func (injector *Injector) Resolve(abstraction interface{})
- func (injector *Injector) SetErrorHandler(handler errorHandler)
- func (injector *Injector) SetLogger(logger log.Logger)
- func (injector *Injector) Singleton(provider interface{}) *Injector
Constants ¶
const ( Binding_Instance bindingtype = iota Binding_Singleton )
Variables ¶
var GlobalInjector = NewInjector()
GlobalInjector is the global repository of bindings
Functions ¶
func Call ¶
func Call(receiver interface{})
Call takes a function (receiver) with one or more arguments of the abstractions (interfaces). It invokes the function (receiver) and passes the related implementations.
func Fill ¶
func Fill(receiver interface{})
Fill takes a struct and resolves the fields with the tag `container:"inject"`
func Instance ¶
func Instance(resolver interface{})
Instance binds an abstraction to concrete for further transient resolves. It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have been declared in the Injector already.
func NamedInstance ¶
func NamedInstance(name string, resolver interface{})
NamedInstance binds like the Instance method but for named bindings.
func NamedResolve ¶
func NamedResolve(abstraction interface{}, name string)
NamedResolve resolves like the Resolve method but for named bindings.
func NamedSingleton ¶
func NamedSingleton(name string, resolver interface{})
NamedSingleton binds like the Singleton method but for named bindings.
func Reset ¶
func Reset()
Reset deletes all the existing bindings and empties the container instance.
func Resolve ¶
func Resolve(abstraction interface{})
Resolve takes an abstraction (interface reference) and fills it with the related implementation.
func SetErrorHandler ¶
func SetErrorHandler(handler errorHandler)
SetErrorHandler sets the global error handler
func Singleton ¶
func Singleton(resolver interface{})
Singleton binds an abstraction to concrete for further singleton resolves. It takes a resolver function that returns the concrete, and its return type matches the abstraction (interface). The resolver function can have arguments of abstraction that have been declared in the Injector already.
Types ¶
type Injector ¶
type Injector struct {
// contains filtered or unexported fields
}
Injector holds all of the declared bindings
func (*Injector) Call ¶
func (injector *Injector) Call(function interface{})
Call takes a function (receiver) with one or more arguments of the abstractions (interfaces). It invokes the function (receiver) and passes the related implementations.
func (*Injector) DisableDebugLogging ¶
func (injector *Injector) DisableDebugLogging()
DisableDebugLogging disables debug logging.
func (*Injector) EnableDebugLogging ¶
func (injector *Injector) EnableDebugLogging()
EnableDebugLogging enables debug logging.
func (*Injector) Fill ¶
func (injector *Injector) Fill(structure interface{})
Fill takes a struct and resolves the fields with the tag `di:"inject"`
func (*Injector) Instance ¶
Instance binds an abstraction to concrete for further transient resolves. It takes a provider function that returns the concrete, and its return type matches the abstraction (interface). The provider function can have arguments of abstraction that have been declared in the Injector already.
func (*Injector) NamedInstance ¶
NamedInstance binds like the Instance method but for named bindings.
func (*Injector) NamedResolve ¶
NamedResolve resolves like the Resolve method but for named bindings.
func (*Injector) NamedSingleton ¶
NamedSingleton binds like the Singleton method but for named bindings.
func (*Injector) Reset ¶
func (injector *Injector) Reset()
Reset deletes all the existing bindings from the injector instance.
func (*Injector) Resolve ¶
func (injector *Injector) Resolve(abstraction interface{})
Resolve takes an abstraction (interface reference) and fills it with the related implementation.
func (*Injector) SetErrorHandler ¶
func (injector *Injector) SetErrorHandler(handler errorHandler)
SetErrorHandler sets the injectors error handler
func (*Injector) Singleton ¶
Singleton binds an abstraction to concrete for further singleton resolves. It takes a provider function that returns the concrete, and its return type matches the abstraction (interface). The provider function can have arguments of abstraction that have been declared in the Injector already.