Documentation ¶
Overview ¶
Package injectz provides a simple, context-based dependency injection framework.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bootstrap ¶
type Bootstrap struct {
// contains filtered or unexported fields
}
Bootstrap builds and manages a group of Initializer.
func (*Bootstrap) Add ¶
func (i *Bootstrap) Add(initializers ...Initializer) *Bootstrap
Add one or more Initializer.
func (*Bootstrap) MustInitialize ¶
MustInitialize runs all the Initializer in the group, returns a compound Injector and Releaser.
type Initializer ¶
Initializer initializes a module, returning a corresponding Injector and Releaser.
type Injector ¶
Injector injects modules into a context.Context.
func NewInjectors ¶
NewInjectors combines multiple Injector into a compound one.
func NewNoopInjector ¶
func NewNoopInjector() Injector
NewNoopInjector returns an Injector that does nothing.
func NewSingletonInjector ¶
func NewSingletonInjector(contextKey, value interface{}) Injector
NewSingletonInjector returns a constant Injector.
type Releaser ¶
type Releaser func()
Releaser releases a module (e.g. closes DB connections).
func NewCloseReleaser ¶
NewCloseReleaser returns a Releaser that calls io.Closer.Close, ignoring any returned error.
func NewNoopReleaser ¶
func NewNoopReleaser() Releaser
NewNoopReleaser returns a Releaser that does nothing.
func NewReleasers ¶
NewReleasers combines multiple Releaser into a compound one (which invokes them in reverse order).