Documentation
¶
Overview ¶
Package alice provides an additive dependency injection container.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseModule ¶
type BaseModule struct{}
BaseModule is an implementation of Module interface. It should be embedded into each module defined in the application.
A typical module is defined as follows:
type ExampleModule struct { alice.BaseModule Foo Foo `alice:""` // associated by type Bar Bar `alice:"Bar"` // associated by name URL string // not associated. Provided by creating the module. } func (m *ExampleModule) Baz() Baz { return Baz{} }
func (*BaseModule) IsModule ¶
func (b *BaseModule) IsModule() bool
IsModule indicates it is a module.
type Container ¶
type Container interface { // Instance returns an instance by type. It panics when no instance is found, // or multiple instances are found for the same type. Instance(t reflect.Type) interface{} // InstanceByName returns an instance by name. It panics when no instance is found. InstanceByName(name string) interface{} }
Container defines the interface of an instance container. It initializes instances based on dependencies, and provides APIs to retrieve instances by type or name.
Click to show internal directories.
Click to hide internal directories.