Documentation ¶
Overview ¶
Package di is a thin wrapper around dig. See https://github.com/uber-go/dig
This package is not intended for direct usage. Only use it for libraries written for package core.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶ added in v0.2.0
type Deps []interface{}
Deps is a set of providers grouped together. This is used by core.Provide method to identify provider sets.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is a concurrent safe, generic factory for databases and connections.
func NewFactory ¶
NewFactory creates a new factory.
func (*Factory) Close ¶
func (f *Factory) Close()
Close closes every connection created by the factory. Connections are closed concurrently.
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is a wrapper around dig.
func (*Graph) Invoke ¶
Invoke runs the given function after instantiating its dependencies. Any arguments that the function has are treated as its dependencies. The dependencies are instantiated in an unspecified order along with any dependencies that they might have. The function may return an error to indicate failure. The error will be returned to the caller as-is.
func (*Graph) Provide ¶
Provide teaches the container how to build values of one or more types and expresses their dependencies. The first argument of Provide is a function that accepts zero or more parameters and returns one or more results. The function may optionally return an error to indicate that it failed to build the value. This function will be treated as the constructor for all the types it returns. This function will be called AT MOST ONCE when a type produced by it, or a type that consumes this function's output, is requested via Invoke. If the same types are requested multiple times, the previously produced value will be reused. In addition to accepting constructors that accept dependencies as separate arguments and produce results as separate return values, Provide also accepts constructors that specify dependencies as di.In structs and/or specify results as di.Out structs.
type Module ¶
type Module interface {
// ModuleSentinel marks the type as a core module
ModuleSentinel()
}
Module is a special interface. A type implements Module to indicate it is a valid core module. This property is examined and executed by the core.Provide in package core. Other than that, the interface bears no further meaning.
If a module is not created by core.Provide, there is no need to implements this interface.